Toolchain for C with pasm
nyholku
Posts: 14
in Propeller 1
Hi,
short background info.
I'm implementing a one off device (so no production) that will count and monitor STEP and DIR pulses in stepper motor control system.
As I have a propeller kit from many years ago and have searched for a worthwhile project to use it in I'm starting with that.
The device will output step counts (and min pulse widths etc) in real realtime much like a milling machine DRO (Digital Read Out),
so the VGA output from the propeller is very attractive.
My thinking is that most of the stuff I will implement in C in one COG but the fast measurement and counting will be done with Propeller assembly language one STEP/DIR monitoring per COG for four steppers.
I would really, really prefer to do this on macOS, though I have Windows 7/10 running in this Mac as well as several Linux distros under VirtualBox.
I've got +40 years of programming all the usual suspects of languages and processors under my belt.
Ok that is the background.
Now to the specific questions.
I've tried both SimpleIDE and PropellerIDE with my eval board and I can get simple example code to compile, download and execute just fine.
I then tried mixing spin and C but this fails with the propeler-elf-objcopy not being able to find the .dat file for the spin code although it seems to compile just fine and I can see the file.
(Sorry can't copy the error message here because SimpleEdit does not support that apparently.)
Reading from the web I got discouraged that maybe this (mixing C with pasm/spin) is not supported by SimpleIDE ?
Moving on I searched for other tool chains.
I see flexgui but I did not find anyone using it on Mac, looks like it [getting it run on macOS] could be done but that would be distraction from the main goal.
I noted fastspin and it seems to support mixing C and pasm but the P1 support looked like it could be sketchy?
Also I read that fastspin C compiles to pasm which is great except does that not limit the code size to very small as it will have to fit into a single COG?
My application is not going to require a lot of code or math (simple integer math and displaying the results on the VGA display) but it seems unlikely that the code would fit in 496 longs.
So please let the crowd wisdom flourish!
wbr Kusti
short background info.
I'm implementing a one off device (so no production) that will count and monitor STEP and DIR pulses in stepper motor control system.
As I have a propeller kit from many years ago and have searched for a worthwhile project to use it in I'm starting with that.
The device will output step counts (and min pulse widths etc) in real realtime much like a milling machine DRO (Digital Read Out),
so the VGA output from the propeller is very attractive.
My thinking is that most of the stuff I will implement in C in one COG but the fast measurement and counting will be done with Propeller assembly language one STEP/DIR monitoring per COG for four steppers.
I would really, really prefer to do this on macOS, though I have Windows 7/10 running in this Mac as well as several Linux distros under VirtualBox.
I've got +40 years of programming all the usual suspects of languages and processors under my belt.
Ok that is the background.
Now to the specific questions.
I've tried both SimpleIDE and PropellerIDE with my eval board and I can get simple example code to compile, download and execute just fine.
I then tried mixing spin and C but this fails with the propeler-elf-objcopy not being able to find the .dat file for the spin code although it seems to compile just fine and I can see the file.
(Sorry can't copy the error message here because SimpleEdit does not support that apparently.)
Reading from the web I got discouraged that maybe this (mixing C with pasm/spin) is not supported by SimpleIDE ?
Moving on I searched for other tool chains.
I see flexgui but I did not find anyone using it on Mac, looks like it [getting it run on macOS] could be done but that would be distraction from the main goal.
I noted fastspin and it seems to support mixing C and pasm but the P1 support looked like it could be sketchy?
Also I read that fastspin C compiles to pasm which is great except does that not limit the code size to very small as it will have to fit into a single COG?
My application is not going to require a lot of code or math (simple integer math and displaying the results on the VGA display) but it seems unlikely that the code would fit in 496 longs.
So please let the crowd wisdom flourish!
wbr Kusti
Comments
I haven't really used the Prop1 myself so can't give actual guidance on tool use, sorry.
As for what you are trying to do with the Prop1, it sounds perfectly feasible.
Counting code can be done without assemble code. I have never had to use SPIN code.
Mike
Combining pasm objects is possible, but its not so easy depending on which compiler you use.
There is another solution that is much slower, but works seemlessly with pasm and that is spin. Spin is a simple high level language which has a builtin pasm interpreter in ROM. The interpreter loads into cog to run. Spin is simple to get used to if you’ve programmed in most higher level languages. If you are not speed constrained i suggest you try this. You won’t be disappointed.
If you need speed, then what you describe sounds easy to do in pasm. P1 assembler is NOT your typical assembler. Its quite easy to learn, and there are masses of help from this forum. Your code will be small and fast. There’s no interrupts to worry about.
Four cogs will handle the four step/dir with ease presuming its not extremely fast, with plenty of time to do basic integer arithmetic. Youll need a cog for the VGA.
One of Eric’s compilers will translate spin or C to pasm for you and you can then take this as a base and modify it to suit.
BTW there are inbuilt timers and counters in every cog so this will help your tasks.
Just ask as you go. Lots of help is here for you
Sorry, cannot help re mac.
fastspin itself is totally supported on P1, it's actually tested more on P1 than P2.
But the first step in all of this is to verify that you actually need to do the programming in assembly. Both PropGCC and flexspin produce pretty fast code, especially for small loops, so you may well be able to do all the capturing in C itself. You can start C functions up on other COGs using the "cogstart" function defined in propeller.h.
https://forums.parallax.com/discussion/157441/can-spi-in-simple-libraries-be-speeded-up/p1
Tom
There is also Catalina. Catalina is known to compile on a Mac, but I have not done so recently as I no longer have access to one. However, just to try it out you could install it on Windows or Linux. There are examples of integrating Spin and PASM with C in the demos\spinc folder which is included in the distribution.
Here is the README from that folder.
Note that this README is a little out of date - since I wrote it, I have also added a PASM function to incorporate individual PASM instructions inline into a C program. This is described in the Reference Manual. Here is a short extract:
You have lots of options!
Ross.
thanks all!
Seems like I do have a lot of options.
I think I will start with C-only.
If that is not fast enough I will look into the other options.
The goal of this device is to just to ensure (or expose) that the STEP and DIR signals meet their specifications. The step signal is max 100 kHz. What I need to ensure is that STEP is not too short. That the STEP signals never come too close together and that the time between two STEP pulses never changes too radically. Also that the time from DIR change to STEP is always higher than a limit.
My thinking is that a single cog will monitor the signals for change and queue them for an other cog to process. This should allow for pretty tight loop in the first cog. If I can figure how ensure that the hardware detects the situation in which a pulse changes back and forth between the first cog sampling the inputs then this should be fool proof and the actual speed is not critical as I expect that this device will (should) NOT detect any violations.
cheers Kusti
For Tk/Tcl installation, see: https://tkdocs.com/tutorial/install.html
Install XQuartz: https://www.xquartz.org
I execute flexgui with the following command, in the XQuartz terminal:
I slightly mod flexgui's source code (src/gui.tcl), to add more-typical macOS file locations, to get the following option-settings:
Not sure if ersmith could "#ifdef macOS" to include these types of changes for other Mac users, but they do work for me :-)
dgately
No need to change the flexgui source code for that. Everything in the "Configure Commands..." dialog is persistent, so you can make those changes in that dialog once and then use them in future invocations. The contents are saved in the .flexgui.config file. If you keep this file across updates you'll keep your changes.