Simple Source Code

Generating Pulse Trains for Step/Direction Motor Drivers

Re: Simple Source Code

Postby andy123 » Tue Feb 05, 2013 4:41 pm

Hi
The simple stepper BOBstep program is giving me the run a round when attempting to assemble through the PBP3 compiler with the #asm #endasm set to cover all the assemble code. The macro _SERPrint will not reference, throws out errors. Any thoughts?
andy123
 
Posts: 6
Joined: Mon Feb 04, 2013 4:39 pm

Re: Simple Source Code

Sponsor

Sponsor
 

Re: Simple Source Code

Postby vegipete » Sat Feb 09, 2013 10:29 am

andy123 wrote:The error listings returned "ASM ERROR progra01 overwriting previous address contents" for large sections of code.
Question; Is the code embedded in the code window in the proper sequence with the ORG statements in the right order?
I've never noticed the order of ORG statements to matter. The assembler builds all the pieces as specified in the source.

I can think of two possible things giving your problems.

I've seen that sort of error message in MPASM when variables in RAM and program in FLASH get mixed up because I haven't correctly told the assembler which is which. Indeed, all my really old source code from many years ago fails with that sort of error when I try to assemble them with the latest MPLAB. This is due to a change in MPASM commands for specifying variables in RAM.

The other possible cause relates to the use of absolute code in my source and how that might interact with the memory model that PICBASIC works with. Alas, I have no knowledge of PICBASIC and can't offer any useful ideas for what to look for. I suppose PICBASIC only expects ASM-ENDASM to contain snippets of code that it can slot into memory wherever it likes whereas the BOBstep code is a complete program with rigid demands (as defined by the ORG and CBLOCK statements) as to where each piece of code and data fits.

Maybe that helps a bit.
/vp
vegipete
 
Posts: 37
Joined: Sat Jul 09, 2011 7:38 pm

Re: Simple Source Code

Postby vegipete » Sat Feb 09, 2013 10:41 am

andy123 wrote:Hi
The simple stepper BOBstep program is giving me the run a round when attempting to assemble through the PBP3 compiler with the #asm #endasm set to cover all the assemble code. The macro _SERPrint will not reference, throws out errors. Any thoughts?
Unfortunately I have no useful thoughts. As you can see, the macro is merely a single CALL followed by the inline text data which gets stored in flash memory. The called routine reads the character string from flash and hammers it out the serial port, then cleans up the stack before returning. I would think the equivalent BASIC statement would be something like [PRINT #port "constant string"] where <port> refers to the desired serial port.

========================
Are you trying to get the BOBstep program running though PICBASIC? That might be difficult if you can't turn off all PICBASIC functionality.
/vp
vegipete
 
Posts: 37
Joined: Sat Jul 09, 2011 7:38 pm

Re: Simple Source Code

Postby andy123 » Sat Feb 09, 2013 11:54 am

Hi
Thanks for the replies. I think I have cracked the ORG snafu. PICBASICPRO inserts an ORG at the start of the basic code automatically and I included the other ORG (reset vector) at ox0000. ''Two ORG's don't an END maketh" (Wm. Shakespear I believe). As for the nice little macro, it is still a challenge. I have always avoided all but the simplest of macros in the past and probably wrote a lot of surplus code as a result. I should really get to grips with the structure of macros properly. I wrote quite a bit of assembler for 8085's in the past and started coding for PICs in the ninety's I find a high level (PICBASICPRO) is a real help in getting things moving but it still needs some assy. code here and there when speed is of the essence.
Anyway, the assembler listings tells me, (x.err, x.lst files) that there is 1; an illegal argument, 2; symbol not listed and 3; missing operand on line 378 viz. [ db sto 0 ] .
I am really wanting to use this piece of software to incorporate in a dual axis stepper indexer driving two Geko's. The ability to input with G code is also very attractive. I have been trying to build a two axis CNC based on the popular EMC suite for CNC but its difficult to keep up with all the changes they keep making to the format, the introduction of the Highlevel Abstraction Layer, HAL for instance. Also my intended CNC set up is quite a simple two axis mover, bit like a plotter really. with an optional rotation axis at a later stage, maybe.
Any help would be much appreciated.
andy123
 
Posts: 6
Joined: Mon Feb 04, 2013 4:39 pm

Re: Simple Source Code

Postby andy123 » Sat Feb 09, 2013 2:51 pm

Hi
Back again. I think you are quite right, the PICBASIC / MicroCode IDE gets a little out of whack with some assembler stuff even when it is inside the ASM / ENDASM wrapper. MPASM is *not* generating an error listing file for the _SERPrint macro. Where the IDE is getting the error listing from I don't know at this point. I will assemble just your lovely chunk of code under MPASM and then when I am happy with its workings, I will pick out the routines that I can incorporate. If all else fails I can use the PICBASIC serial I/O routines to get the characters out to screen. Thank you for your guidance. How is the latest iteration of the G code interpreter going?
andy123
 
Posts: 6
Joined: Mon Feb 04, 2013 4:39 pm

Re: Simple Source Code

Postby vegipete » Mon Feb 11, 2013 10:31 am

andy123 wrote: If all else fails I can use the PICBASIC serial I/O routines to get the characters out to screen. Thank you for your guidance. How is the latest iteration of the G code interpreter going?
The ISR is the part that does all the heavy lifting for generating the stepper pulse trains. It is a 2-axis engine, so it should serve your needs, at least to start. If you can get the ISR running happily behind your PICBASIC code, you should be laughing. The "Start_Move" function shows how to feed the ISR to get it to perform a move. The tough part might be the serial receive routine. The ISR polls the serial receiver and maintains the receive queue and the hardware handshaking. This is unlikely to mesh nicely with PICBASIC so you would likely have to write your own code to pull characters from the receive queue. Follow the code starting from "move_loop" to see how my code does that.

My G-Code interpreter is advancing. It is about ready for presentation, requiring documentation so others can make sense of it. 2 1/2 axis, inch/metric linear moves and feedrates and some other goodies are working nicely. Soon.... :-)
/vp
vegipete
 
Posts: 37
Joined: Sat Jul 09, 2011 7:38 pm

Re: Simple Source Code

Postby andy123 » Mon Feb 11, 2013 12:36 pm

Hi
Thank you for your help. It is much appreciated. I was working on the hardware for the serial interface last night, (cable, ser to usb etc. Hope to get it going soon. Thank again and look forward to seeing your G code int. soon.
Cheers Andy
andy123
 
Posts: 6
Joined: Mon Feb 04, 2013 4:39 pm

Re: Simple Source Code

Postby andy123 » Sat Feb 16, 2013 9:23 am

Hi
I re-visited the Simple source code again to see if I could incorporate the LCD routines into my PICBASICPRO code to speed things up a little. The PBPC commands to output control and data commands to the Hitachi LCD controller take a chunk of my lifespan to execute. I thought assy code here would speed things up as I want to run the steppers up to 12Khz and show position on the LCD for two axes, (The GEKO's are in microstep mode, thousands of steps per rev). Have you any feel for the LCDprintnum execution times? There seems to be a lot of pausewms and pause100us's for it to be a practical solution. My thoughts, if displaying whilst moving is un-feasable is to monitor the X Y clock pulses externally and update a separate display counter. OR, use seven segment direct addressed displays. Rather retrograde move but........
I have run steppers at high speed in the distant past (Berger Laer Quinstep 5 phase) using an external clocking scheme with a UJT ramping pulse generator feeding the timer inputs on 8085 peripheral interface (8155), using the interrupts sense end of move ramp down point. I worked well past 5Khz with the 8084 clocking at 1Mhz (6.144Mhz crystal). My current platform PIC is a PIC18F4550 with a 20Mhz res. Seems like a Porsche compared to the 8085!
Thank for all you help whilst I grope my way forward.....
andy123
 
Posts: 6
Joined: Mon Feb 04, 2013 4:39 pm

Re: Simple Source Code

Postby vegipete » Sun Feb 17, 2013 4:55 pm

Handling the LCD may be somewhat time consuming, especially since you see all the wait functions, but all that runs as the main routine. The ISR in the background generates the steps regardless of what the front end is spending its time on. Serial port output without a TX FIFO isn't overly quick either given that the main routine spends some amount of time waiting for space in the TX buffer for the next character but it stills works just fine without affecting the step pulses. Your 12kHz step rate should be easy if you can get the ISR running solidly in the back ground. Then it doesn't really matter much what your foreground basic program is doing.

My more advanced G-Code interpreter version is more or less the same ISR engine with a much more advanced front end.

If the front end is truly glacial, the result will be (noticeable) delays between discrete moves but the moves themselves will be smooth and accurate.
/vp
vegipete
 
Posts: 37
Joined: Sat Jul 09, 2011 7:38 pm

Previous

Return to Stepper Speed Ramps

Who is online

Users browsing this forum: No registered users and 1 guest