# ApplePi



## jcdammeyer (Oct 1, 2022)

A Raspberry Pi is annoying in that you have to connect a power supply  and mouse and monitor and keyboard.  Wires everywhere.  You can buy a Pi400  https://www.canakit.com/raspberry-pi-400.html  but then you still have to add a monitor so still a pain. 

Now granted this ApplePi won't control the hardware on the Pi4 but for writing software for it and just generally having a linux box instead of an Apple Laptop that is not supported and whose web browser chokes on most web pages this isn't bad.






The Apple is an A1278 model.   https://gadgets360.com/apple-macbook-pro-a1278-7523

More as I start to use it.  It's being charged.  I don't remember if the battery holds a charge anymore.  It has been replaced once.  My wife has a much newer macbook now.


----------



## 6.5 Fan (Oct 2, 2022)

I prefer Apple Pie......moonshine. Computers just confuse me, make me want to drink more.


----------



## Susquatch (Oct 2, 2022)

jcdammeyer said:


> A Raspberry Pi is annoying in that you have to connect a power supply and mouse and monitor and keyboard.



It's not clear to me what you are trying to do jc?

I've looked briefly at the Raspberry stuff and concluded it primary market target isn't me. Too much other stuff needed to make it go and no real advantage over an old laptop/tablet/pc. I suppose it makes sense for someone wanting to make and sell a dedicated program pre-installed on a dedicated affordable device, and they are very powerful little computers for the price, but I don't think they are for me. I don't know what I'd do with one. Hence my curiosity with your plans. 

I confess that I bought an Arduino and an LCD display for it and fully planned to make an rpm display with it, but the need fell away when I got a DRO with RPM. That said, it's something I want to do just for the fun of controlling things. 

I noticed recently that there is an Arduino with one D/A output. I also noticed that the new IDE V2 is released. I'm hoping this winter brings time to play with it and also to learn more about Fusion 360. Too much fun for an old man.


----------



## trlvn (Oct 2, 2022)

Susquatch said:


> It's not clear to me what you are trying to do jc?


+1

The Mac you have is more commonly referred to as a 'mid-2012 MacBook Pro':





__





						MacBook Pro 13-Inch "Core i5" 2.5 Mid-2012 Specs (Mid-2012 13", MD101LL/A*, MacBookPro9,2, A1278, 2554*): EveryMac.com
					

Technical specifications for the MacBook Pro 13-Inch "Core i5" 2.5 Mid-2012. Dates sold, processor type, memory info, hard drive details, price and more.




					everymac.com
				




I've got a late-2011 MBP that my son used in school.  It is still running OS X 10.13 and I use it mainly for testing some software from MacPorts:





__





						The MacPorts Project -- Home
					

The MacPorts Project is an open-source community initiative to design an easy-to-use         system for compiling, installing, and upgrading either command-line, X11 or Aqua based open-source software on the Mac         OS X operating system.



					www.macports.org
				




MacPorts makes available thousands of pieces of software from the open source community.  Several contributors are very enthusiastic about supporting older Macs with older OS versions.  A surprising number of things will still run on old PPC Macs running OS X 10.4!  Of course, there is also support for Apple's new M-series processors running the latest macOS versions.  

Craig


----------



## VicHobbyGuy (Oct 2, 2022)

jcdammeyer said:


> Now granted this ApplePi won't control the hardware on the Pi4 but for writing software for it and just generally having a linux box instead of an Apple Laptop that is not supported and whose web browser chokes on most web pages this isn't bad.


I'm confused - do you like that Macbook (a.k.a. Apple laptop) with the Pi or not?

Off topic: I have a couple of Macbooks from that era. If it's a Pro, it usually says so on the display border. Also, there are ways of running newer OS versions on old Mac hardware that work pretty well (search for Dosdude1). All stuff for a different forum perhaps; apologies for the distraction.


----------



## jcdammeyer (Oct 2, 2022)

I'll try and answer the questions.  
I'm a PC guy, not a MAC guy because 99% of the software I use isn't available for a MAC and none of my customers use MACs.  That may be changing now but as yet hasn't.  

Same with Linux as a base system.  I still laugh at a guy I knew who used to bad mouth Windows any chance he got.  Was a pure Linux fan.  Then when he wanted 'free' CAD software he had to buy a WIN-10 laptop in order to run Fusion which wasn't available on Linux.  Not sure why he didn't run a virtual PC but maybe Fusion doesn't like that either.  And he was running MACH3 on his Mill although I tried to get him onto LinuxCNC for that.  

My wife has a MAC for her email and internet usage and my older son uses MACs.   For what my wife was doing the old MAC couldn't cut it anymore so we replaced it.

I do embedded systems so it's useful for me to know about Beagles and Raspberry Pi systems.  I have an old Pi2 as the network interface using OctoPi to my 3D printer.  After the last fiasco where the OS on that was updated automatically and broke much of what I had configured I no longer update that Pi2.  It's now like my 1936 bandsaw.  Turn it on, cut something, turn it off.

A few years ago I did a project capturing CAN messages from the Ignition ON event for an electric vehicle and then CAN messages and GPS information for the duration of a journey.  I had to write that software for a PIC32 embedded processor and then have the PiZeroW capture that and store it for later upload onto a Cloud.  All because Linux systems take at a minimum about 20 seconds to boot and you lose critical information during that time.






I'm now using another module I developed that has a dsPIC30F series processor module called an Extendable Interface Module, (xIM) which a dual relay companion board making it a modified Generator Interface Module (GIM) to run the air cylinders and pneumatic butterfly for the power draw bar.




The photo above is the test panel.  To develop the LinuxCNC software to talk via CANopen to it I had a Raspberry Pi4 + MESA Ethernet interfaced 7i92H + a couple of Breakout Boards (BoBs) wired up on my bench.  The CAN bus connection from the Pi4 to the GIM was via a Swedish Lawicel CANUSB so at the moment I'm not using my CAN HAT for the Pi.





						LAWICEL CANUSB | canusb.com
					

LAWICEL CANUSB - A versatile CAN to USB Interface Converter with an open API on canusb.com



					www.canusb.com
				




When I found I could put the complete Pi OS onto Linda's old MAC and not have the myriad of wires etc just for writing and testing software out the USB port it seemed a good solution.   But I don't know yet if I can update the Pi OS to run LinuxCNC.  Working on that...

Another reason for the BeagleBone and Pi was for potentially creating a new version of my ELS for users to upgrade.  The idea was that with an adaptor it would plug into the CPU socket of my ELS and give people an enhanced ELS with the same user interface but could also run full CNC.  

At this point I've abandoned the BeagleBone because the OS and therefore embedded software changes constantly.  The Pi was never able to do real time stuff until the Pi4 showed up so now people have it running LinuxCNC and that's been an interesting experiment.  But so far that's all it is.

Anyway, with the Mac and Pi OS I can sit here upstairs in front of the TV keeping my wife company instead of downstairs buried in my office.   I can write the Pi software instead of using VNC which I find slow and annoying.  Maybe.  Might all be a waste of time.    

For utilities for LinuxCNC I use the Lazarus IDE which is Object Pascal in an environment that looks like Delphi 7.0.  Write once, compile anywhere is the motto for that.  And so far I've written code in it that runs on my PC, Pi3, BeagleBone and LinuxCNC PC all without a single line of code change.






Anyway, that's my ramble for now.


----------



## VicHobbyGuy (Oct 2, 2022)

So you have replaced the OS X on the Mac with a different OS so you can use Pi?


----------



## Susquatch (Oct 2, 2022)

@jcdammeyer - believe it or not, even sick w covid and a foggy brain, I believe I followed all that.

Conclusion...... You sir are crazy!

Well ok, maybe not crazy but certainly a glutton for self punishment..... Holy Crap!

I am a PC guy too. I can use a Mac, but I don't like all it's strict interface rules and structure. I prefer more access and flexibility. 

On the surface of it all, it sounds to me like you would be better off with a PIC Controller or even a D/A/D conversion board for the regular PC bus. Or perhaps even a standalone Programmable Controller that just uses a PC or Mac as a terminal device for programming and control. Or maybe even make your own controller from scratch. I know that would rule out external libraries and code, but it sounds like you are already leaving a lot of that behind you anyway.

On a personal note, my hat is off to you for having the kind of mind that can manage all that complexity and still stay sane! I think you missed your calling as nuclear physicist.


----------



## jcdammeyer (Oct 2, 2022)

VicHobbyGuy said:


> So you have replaced the OS X on the Mac with a different OS so you can use Pi?


I have replaced the Unix (MacOs) with Linux that runs on the MacBook AMD processor.
The user interface part of this Linux is the same one that runs on the PI.
And that's why it's called the Pi OS.
The ISO file installed on the USB drive also booted up a Fujitsu laptop that runs Vista. 
You have the option of install or just run from USB drive. I installed onto the MacBook.


----------



## VicHobbyGuy (Oct 2, 2022)

Thanks, that helps a bit!


----------



## jcdammeyer (Oct 2, 2022)

One of my big complaints, and I'm really guilty of it too, is that the writers of a post make assumptions that everyone else is at the same level of understanding.   So they tend to gloss over details perhaps for trying not to sound to condescending. 

So let's back up a bit here.  The hype from hardware and software manufacturers has obscured some very basic details.  The Operating System (OS) of a computer has come to describe the entire system from hardware all the way up to what you see on the display.  But in reality the system really consists of only a few parts arranged in layers.

At the very bottom of course is the actual hardware and there has to be software that interfaces to that physical world.  As simple as instructions to turn a fan on or off.  The software that does that is often called device drivers or BIOS (for basic input/output system).  This provides a layer of abstraction between the physical world and the software world.

Much easier to have your software call PinOut(number, value) that is the same regardless of the underlying hardware.  In Linux this is called the Hardware Abstraction Layer (HAL).   Even the Arduino hides the physical hardware from you by providing libraries of routines so that you can turn on an output from the same code even if it's meant for one of about 20 different flavours of hardware that have the Arduino interface.

Above that BIOS or HAL or whatever, you now can have libraries that talk to hardware and perform specific tasks.  Like interfacing to Video Screens or Keyboards or USB or Ethernet Hardware.  Once again these libraries have common input and common output to interact with the code above and below.

So far we haven't got a MAC or a PC or a Pi or any other kind of machine.  But that's the basic operating system.  The current crop of Apple Mac's run I think BSD Unix.    Microsoft with WIN-11 is moving to having that interface with the hardware be Linux.  Your Android Tablet or phone is running Linux.  If you have a router in your house to connect TV, PCs, Gaming consoles etc. it's likely running a version of Linux.

But that's not the Linux user interface part.  It's the hardware and library interface part.  The user interface is on all the systems can often still be the archaic 1970's command line like the old Apple 2, MS DOS or CP/M-80 or DEC PDP-10/11 or even the IBM mainframes.   And from that command line in the background and often not easily accessible is the running of a program that starts a graphical user interface.  Complete with access to the touch screen hardware, sound system, network and storage.

That user interface is what you see on a MAC, Android, PC, Raspberry Pi etc.  - Underneath they are all basically the same and more and more based on the Linux core.

So if someone has access to the hardware information for say a 2012 MacBook Pro and can write the code to access that hardware so that it then uses the Linux libraries adding in the code that creates the Raspberry Pi user interface is trivial.  In most cases on PCs (laptops) the BIOS is in Read Only Memory (ROM) specifically for that hardware so again the device drivers and HAL in a Linux system just have to be tailored to the BIOS calls and now you have Linux on the PC.  And if the Graphical User Interface (GUI) is the Raspberry Pi one (generally written in C, Python and a few other common languages) then that laptop now looks and feels like a Raspberry Pi.  Except you can't interact with Raspberry Pi hardware like I/O pins or SPI or I2C because it's not physically there.

Hopefully this long winded explanation can clear things up?


----------



## VicHobbyGuy (Oct 2, 2022)

Thanks, John. 
I'm light-years away from your level. After multiple (totally unenjoyable) attempts in the past, I'm FIRMLY in the "Tried LINUX several times; didn't like it" camp, thus disqualifying me from conversations like this. I manage to install OS X in a Mac - that's about it.

Anyway, I don't understand how you arrange the filament (heater) supply for the tubes in those electronic setups, and keep everything cooled.


----------



## jcdammeyer (Oct 2, 2022)

VicHobbyGuy said:


> Thanks, John.
> I'm light-years away from your level. After multiple (totally unenjoyable) attempts in the past, I'm FIRMLY in the "Tried LINUX several times; didn't like it" camp, thus disqualifying me from conversations like this. I manage to install OS X in a Mac - that's about it.
> 
> Anyway, I don't understand how you arrange the filament (heater) supply for the tubes in those electronic setups, and keep everything cooled.


I'm in the "I Use Linux, Don't like it!" camp.  I like the Pi and LinuxCNC but I'm not using the command line there.  At least rarely.  What I don't like about Linux is the default to the command line for everything.  Especially where there is Lazarus Object Pascal available for GUI interfaces.

Like I showed in that earlier posting of the Make Bore program.  That was a C command line program that I ported to Pascal and instead of a bunch of question and answer lines at the command line, fill in the blanks.

But as far as the filament heater cooling.  I'm afraid I'm not allowed to tell you how that works.  If I did I'd then have to have you bitten by a vampire and finished off with a stake through the heart.


----------



## Susquatch (Oct 2, 2022)

jcdammeyer said:


> Hopefully this long winded explanation can clear things up?



You might call that long winded, but I think it's about the shortest description I've seen in 50 years!

Maybe that's because I have forgotten more than I remember. 

The one aspect you glossed over a bit is the level between the BIOS and the HAL (A new term for me that I would have called that layer the BDOS). As you describe, it is supposed to be very structured with a very well defined set of entries and exits that all make sure the hardware independent layers above talk to the hardware below in OS calls and return terms they both understand. 

In my simple mind, this is where the biggest difference between the Apple and the PC resides. That's because in a PC all software is supposed to use the proper interface levels but doesn't have to while in an Apple it must - no ifs ands or buts. Therefore pc software companies often write software that talks directly to the hardware at optimal speed while Apple software has to make the proper BIOS/BDOS calls as defined in the Apple API. 

I mention this observed difference mostly because I perceive that you are one of those evil (just kidding) characters who are most likely to break the rules and talk directly to the hardware. I'm not far behind you. Hence my earlier post about directly using Arduino Interrupts and timer registers. For speed critical applications and control, it is often necessary to break the chain of command and communicate directly from top to bottom and back. That isn't without its risks, but the speed and control payoff benefits can be worth it. 

Anyways, like I said - well written.


----------



## jcdammeyer (Oct 2, 2022)

Susquatch said:


> The one aspect you glossed over a bit is the level between the BIOS and the HAL (A new term for me that I would have called that layer the BDOS). As you describe, it is supposed to be very structured with a very well defined set of entries and exits that all make sure the hardware independent layers above talk to the hardware below in OS calls and return terms they both understand.
> 
> In my simple mind, this is where the biggest difference between the Apple and the PC resides. That's because in a PC all software is supposed to use the proper interface levels but doesn't have to while in an Apple it must - no ifs ands or buts. Therefore pc software companies often write software that talks directly to the hardware at optimal speed while Apple software has to make the proper BIOS/BDOS calls as defined in the Apple API.


Thank you.  I found this one article that describes the kernel a bit.
https://developer.ibm.com/articles/l-linux-kernel/ 

With the newer processors and fear of viruses it's no longer possible on any of the platforms to directly access the hardware.    Easier to do with the hardware too.  User programs just can't get into the supervisor area.  For example, FTDI who make the USB chips, allocated the PID numbers of which I had 3.  The file used for installing this had that number and other information about the type of USB interface.  With WIN-10 you can no longer do that unless you get the driver file and number licensed and that costs $5K.  So we went back to the generic serial port for all our hardware.

So on Apples and PCs you can't get at the hardware.  That's why MACH3 doesn't run on WIN-10.  You must now buy a USB or Ethernet based dongle that does the interfacing and run MACH4 instead.  That's why I have the MESA 7i92H which duplicates two parallel ports.

Linux still allows access to parallel ports.  The HAL and INI files are the installers connection to LinuxCNC.  Once you get a handle on how that stuff works (and some of it's a bit obscure) suddenly LinuxCNC isn't that hard.  MACH3 was still easier and I still run it for my CNC router.

But Linux is brutal.  I did the apt-get for Free Pascal and Lazarus and tried to run it and it immediately ran into problems with some sort of permissions.  Installed alright.  But something is wrong.  But the Lazarus support group is very good so I'm sure I'll solve the problem at some point.

Does eat away the hours though...


----------



## trlvn (Oct 2, 2022)

jcdammeyer said:


> The current crop of Apple Mac's run I think BSD Unix.


Since we're well off into the weeds, I'll quibble that this is oversimplified.

The low level operating system on Mac hardware came from NextStep when Apple bought Next and brought Steve Jobs back into the company.  NextStep did derive from BSD but with significant alterations.  Key among those was using the Mach microkernel (now called XNU).  This kernel now underpins macOS, iOS, iPadOS, tvOS and watchOS.  AIUI, no other major operating system uses such a kernel.  Perhaps one of the specialized real-time operating systems does now.

The command line interface on macOS is ported from BSD with some changes and additions.  I believe using BSD is largely driven by licensing considerations.  The various versions of GPL connected with Linux and other unixes would create restrictions or outright roadblocks for a commercial operating system.

Wikipedia has an overview article on Mach:





__





						Mach (kernel) - Wikipedia
					






					en.wikipedia.org
				




Apple has an introduction at:





__





						Kernel Architecture Overview
					

Essential information for programming in the OS X kernel. Includes a high-level overview.



					developer.apple.com
				




Craig


----------



## jcdammeyer (Oct 2, 2022)

trlvn said:


> Since we're well off into the weeds, I'll quibble that this is oversimplified.
> 
> The low level operating system on Mac hardware came from NextStep when Apple bought Next and brought Steve Jobs back into the company.  NextStep did derive from BSD but with significant alterations.  Key among those was using the Mach microkernel (now called XNU).  This kernel now underpins macOS, iOS, iPadOS, tvOS and watchOS.  AIUI, no other major operating system uses such a kernel.  Perhaps one of the specialized real-time operating systems does now.
> 
> ...


Thanks Craig.  Very interesting reads.
John


----------



## Susquatch (Oct 3, 2022)

jcdammeyer said:


> With the newer processors and fear of viruses it's no longer possible on any of the platforms to directly access the hardware.



Ouch! I wonder how they prevent that? I guess it was inevitable though. Sooner or later keys to the safe were gunna happen. We can thank all those crooks and hackers out there with evil intent for that. 

Kudos to you for your perseverence and skill. Where there is a will there is a way!

Another reason for your interest in the Pi I guess. If I were doing it (and I'm not), I would probably develop a PIC or dedicated controller that took character based output (think printer or USB Communication) to generate code to control my hardware and move totally away from PCs and Macs other than for the printing/USB Control output. 

Funny how progress is a circle. The very first program that I made money on was a communication program designed to trick mainframes into thinking they were getting keypunch input (think card stacks) when they were really getting input from a dumb terminal running CPM on an 8080. I used the CPM system to write and edit the simulation programs which were then run on the protected mainframes. 

I can see the day now when a Pi or PIC or Arduino or whatever does the same to a protected PC. The PC wouldn't even know it had been bypassed. 

Someday we will use FemtoControllers to bypass the Pics and PI's and Arduinos.......


----------



## PaulL (Oct 3, 2022)

Susquatch said:


> Ouch! I wonder how they prevent that?


The TPM "Trusted Platform Manager" which is a separate chip that can validate certain pieces of state in the main processor and report back that all is "well".  You can usually still turn it off, but many modern operating systems won't function without it because it might allow you to use the machine and software you purchase in a way not intended by its makers.  Which is to say that you haven't purchased it at all.
Linux doesn't do this which is one of the reasons it's so popular in both the hobbyist community and in large data centers where a lot of the hardware doesn't look like consumer hardware. [edit: spelling - I don't know how you can do this on your phone, Sus]


----------



## Susquatch (Oct 3, 2022)

PaulL said:


> The TPM "Trusted Platform Manager" which is a separate chip that can validate certain pièces of state in the main processor and report back that all is "well".  You can usually still turn it off, but many modern operating systems won't function without it because it might allow you to use the machine and software you purchase in a way not intended by it's makers.  Which is to say that you haven't purchased it at all.
> Linus doesn't do this which is one of the reasons it's so popular in both the hobbyist community and in large data centers where a lot of the hardware doesn't look like consumer hardware.



Very interesting. I didn't know about TPM. I did a little digging. Apparently the latest microprocessors from Intel have the TPM processing built right in so a separate chip isn't needed.

Now I know why so many recent programs are installing with hardware signatures for piracy protection. (a PIA for legit users).

Most of what I read relates to piracy protection not hardware access level protection.

Anyway, thanks for telling me something I didn't know about.


----------



## jcdammeyer (Oct 3, 2022)

Susquatch said:


> Another reason for your interest in the Pi I guess. If I were doing it (and I'm not), I would probably develop a PIC or dedicated controller that took character based output (think printer or USB Communication) to generate code to control my hardware and move totally away from PCs and Macs other than for the printing/USB Control output.


Back in around 2006 when the monitors were still glass tube based and big and PCs were large and laptops really expensive many of us wanted to be able to do metric threading on our imperial lathe.  I just wanted to be able to thread on my Gingery lathe without all the extra work of making gears first.  For small lathes and the occasional threading no one wanted a PC etc larger than the lathe itself or actual CNC.

So the ELS was born.  The CAD_CAM_DRO group,  MACH group, and DIY_CNC groups all said we were nuts and some members were actually quite abusive at the time.  So we formed the E_Leadscrew group.   Moderated to stay on topic, no abuse tolerated. 

One member from Australia who was totally against the project even went so far as to whip up a simple display, two buttons and a rotary knob version.  Kind of like the electronic gearing you see now.  No one was interested in something like that.    Using a knob to scroll through 0..9, click button, scroll 0..9 for the next digit etc.  If my KitchenAid stove/oven had that interface for setting oven temperature or timer we wouldn't have bought it.  Most members on the group agreed that human factors engineering was really important and that includes a keypad.

Your comment about duplicating a keyboard brings back memories too.  Back in the 90's a client of mine needed what's in this photo.  Microchip PIC based it duplicated the old style IBM keyboard protocol, before USB.  I wrote the software for it.  Even then his customer didn't want a rotary knob to enter in numbers one digit at a time.





But to return to your comment.  The ELS, which even included a micro-stepper driver for the carriage was the inexpensive, non-PC solution.  Now the two chips for the micro-stepper cost more than a leadshine drive from amazon.ca so it's no longer part of the kit. 

I actually used a BeagleBone black along with a CNC cape that had parallel port emulation to first run my mill.  From May 2018 a 30 second video show Y and Z motion run with the BBB.  I had hopes of turning the BBB into an ELS that could, with monitor/keyboard/mouse added become full CNC or just back to LCD display and keypad the ELS.  So simple power feed and all the DRO type operations or full CNC. 





But the cape required Normally open limit switches and support for MachineKit (LinuxCNC on the Beagle) dropped so the project did too.
Here's the overall view with two axis controlled.




A close up of the Beagle right above the mouse there and in the background the HP_UHU DC servo drive run with a 105VDC power supply.




The knee was still run with a Gecko Stepper drive and a 60V power supply.




And finally the 105 VDC power supply with the BoB.  The supply had over voltage clamping, reduced current startup and fast drain of the capacitors on shut down.




The point to all these pictures is the one we made often on the E-Leadscrew group.  The controller can be very small.  The infrastructure is pretty well always BIG.

Time to go do something constructive....


----------



## Susquatch (Oct 3, 2022)

jcdammeyer said:


> The point to all these pictures is the one we made often on the E-Leadscrew group. The controller can be very small. The infrastructure is pretty well always BIG.
> 
> Time to go do something constructive....



Good stuff John. I'm quite impressed!


----------



## CWret (Oct 6, 2022)

All this is way over my pay-grade/ability/experience but it has been an interesting read. Even if it is over my head. Thank goodness for Microsoft - I love the ease of using Word, Excel, PowerPoint, and Project. 
More than 50 years ago, when I was still using a slide rule, I took a short course in FortranIV. That's my only experience with programming or coding and that was using punch cards. My only fear then was getting into an uncontrolled DO loop.

CW


----------

