View Full Version : Do pulses CTRA / TFRK?
05-21-2008, 10:08 PM
I have a question
With CTRA / TFRK registers open generate a certain number of pulses?
I want to control the number of pulses
P 1000 at a frequency of 150kHz
I believe that we can not because CTRA / TFRK operating in Loop
I'm not sure
How can you do?
Envio editado por (hal2000) : 5/21/2008 3:56:37 PM GMT
05-22-2008, 05:30 AM
funny picture http://forums.parallax.com/images/smilies/smile.gif
i'm not familiar with the counters. I think it is possible.
You should edit your threadtitle that way that the title already gives all important information
something like "can counters be used to create a well defined amount of pulses?"
another way would be to code this in assembler
150 kHz = 6,67 microSecs
this should be possible in Assembler
in assembler you could use the command djnz
Usermanual page 370:
DJNZ: Instruction: Decrement value and jump to address if not zero.
most commands in assembler take 4 clockcycles
at 80 MHz 1 clockcycle is 12.5 nanoseconds
so 4 clockcycles is 50 nanoseconds
so 6,67 microseconds gives you 6,67 / 0,05 = 133 commands
the fastest way to create pulses would be a loop that uses the xor and the djnz-command
as a raw picture a code-snippet (that needs some more code for working
mov _mP_long, par '_mP_long contains the number of loops
LoopStart xor OutA, _toggleBit
djnz LoopCntr, #LoopStart 'decrement "LoopCntr" jump to label "LoopStart" if "LoopCntr" not "0"
_toggleBit long |< 3
LoopCntr res 1
_mP_long res 1
two commands with 4 clockcycles = 8 clockcycles = 0,1 Microseconds
this would toggle PIN3 at 0,1 MicroSeconds = period 0,2 MicroSeconds = 5000 kHz
for 150 kHz you could even use the WAITCNT-command
for more information about assembler see
05-22-2008, 07:08 AM
My image, ;-) I like black humor http://forums.parallax.com/images/smilies/skull.gif
Sorry for my bad English
I'm learning English, four months ago
You're right the best way is to assemble
I am thinking to make a program that controls 4 stepper Motor·
Using 4 controllers for motor, propeller only has to generate steps and address
As I use micro steps need to 150kHz (only possible to assemble)
The idea is to make a library that controls the 4 engine with variable 5
frequency of steps (speed)
acceleration is to define a speed of transition from one sequence to another
A list of serious data
1 steps memory address frequency acceleration
Memory 2 1000····· · 1············ ··5khz············ 200······· (steps of transition from 100Hz to 5Khz)
Memory 3 300······· ·1············· ·10Hz··········· 300········(steps transitional 5Khz a10hz)
Memory 4 500······· ·1·················0hz························· (0hz is stop during 150khz/500· pause)
This is a possibility, I'm thinking about it
I'm looking for a book, I can not find any library
I'm trying to understand the propeller of assemble, gradually
I believe that this routine is not difficult to schedule
With my little knowledge, it is difficult for mi
you have a better idea?
Any suggestions would be welcome
05-22-2008, 08:09 AM
If you are looking for a simple 50% duty cycle frequency it should be rather easy to do. All you need to do is setup the counter to do it's thing then do a waitcnt for the amount of time it would take to produce the number of cycles you need to produce, then stop the counter. It may take a little bit of fiddling with the timing if you need to have the time period be precise since there's going to be a little slop due to the overhead of execution between starting the counter and entering the waitcnt (and turning off the counter).
BTW your english is very good for somone who has just started to learn.
Paul Baker (mailto:email@example.com)
Propeller Applications Engineer
Parallax, Inc. (http://www.parallax.com)
05-22-2008, 03:14 PM
(i like playing with words)
there are sevreal threads about driving stepper motors
try a search with the parallax-google searchfunction
this is much more effective then the build-in function
in this one AxisDriver.spin the assembly-code is quite good commented
but there are minmum three more threads with sourcecodes in assembly
To move 2 axis at the same time you can use the "Bresenham-Algorithm"
The "Bresenham-Algorithm" needs only addition and substraction of INTEGERs to calculate everything
it does NOT need multiplication or division or floating-point-calculation
by googling i found this PDF
there are o lot more hits for this keyword
Also search the propellerforum about steppermotors
05-22-2008, 06:17 PM
What you want to do is possible because I have done something very similar myself, my code is based on the way the g-rex motion controller works:
finance.groups.yahoo.com/group/geckodrive/ (http://finance.groups.yahoo.com/group/geckodrive/) See files section for details
You can see it operating some steppers on my youtube account
Essentially you have a loop that lasts a fixed length of time, at first you increment the frequency (frqa) by a given amount on each loop to accelerate the motor, then you keep the frequency for the transition as you call it before decrementing the frequency on each loop to decelerate. You do not need to count pulses you just use the loop time and frequency. You have to be careful of things like short moves where there will be a triangular motion profile and also because the loops are fixed time lengths you will need to adjust the final frequency to ensure you reach your target.
It is possible to do multi axis moves by considering them as vectors, one cog can do two axes easily and you could sync multiple cogs for more. I have not done this yet as at the moment I have no need.
Can you have the code you ask? Well at the moment no. I have found that in the CNC community people are very opportunist and I know for a fact that the moment I release the code it will turn up in a dozen products. Plus the concept was not mine and I think the g-rex was an open source project originally and although I have used none of their code I have taken inspiration from the ideas, I'm not sure what to do.
05-22-2008, 11:27 PM
I see a lot of information
Thanks to all
long time in assimilate into so much data
English => head processor (aid Goglee) + professor of English = IspanIngles interpreted.
In English there is good information
It is important, I have to learn English
Very good document StefanL38 "PDF" I had some doubts resolved.
Graham, quiet do not want to be a seller of CNC controllers
I would like to have a CNC machine, but it's not my goal.
I want to learn everything I can.
What I like most is to do experiments
I work as a technical post-production and camera operator
My experiment Timelapse
I put on youtube the things I enjoy, there is no professional work
This will clarify for the curious.
I put a link from the driver that I use
I long days (I think months) to understand as information ;-)
05-23-2008, 06:20 AM
Well I think your best way to proceed is to learn to program in assembly and start creating pulses for your motors, it will not take you long and we are all here to help.