Ctrmode ?
anita1984
Posts: 23
I have been doing a lot of reading and playing with sample codes( Spin language), but I’m missing something.
I believe the code I need will only be a dozens lines, so I keep reading and trying.I want to control the speed of a motor( in Propeller Assembly language with spin language at the begining) input (1 up to 4KHz and duty cycle 50%).I don't know in this case what is better to choose CTRMODE : %0001X for clock generation or CTRMODE : %0010X NCO ????
NB: i don't need to generate a PWM signal, the synth.spin in library working perfectly to my needs.
Thank you in Advance
Post Edited (anita1984) : 11/9/2008 5:11:06 PM GMT
I believe the code I need will only be a dozens lines, so I keep reading and trying.I want to control the speed of a motor( in Propeller Assembly language with spin language at the begining) input (1 up to 4KHz and duty cycle 50%).I don't know in this case what is better to choose CTRMODE : %0001X for clock generation or CTRMODE : %0010X NCO ????
NB: i don't need to generate a PWM signal, the synth.spin in library working perfectly to my needs.
Thank you in Advance
Post Edited (anita1984) : 11/9/2008 5:11:06 PM GMT
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
I am trying to convert it to Assembly propeller language , but i found alot of difficult
Thank you for you answer
Post Edited (anita1984) : 11/10/2008 8:55:15 PM GMT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
But if you are looking on how to do it to teach yourself,· or you intend to do more complex things in assembly (either with the counter, or not), you would use a modified version of the program listed on page 7. It would be modified to look like:
The value 80530 was obtained by using AN001 equation 1, setting fHz = 1500 and system frequency to 80,000,000 and solving for FRQA.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Post Edited (Paul Baker (Parallax)) : 11/17/2008 4:45:50 PM GMT
I am doing some counter work and reviewed the AN001 and did some searching and came across this post. In your example above, I see you calculated a period, but it isn't used in the code you posted. Did you mean to include a loop with waitcnt and the period?
I am trying to use the AN001 page 7 example. I have an assembly routine for an LCD I am working on. The routine has different commands for sending commands or data to the display. One of the commands I am setting up is for the LED back light. I would like to use a counter to control the back light. With this method the counter can be set and the code can go on and do other work. I am searching out examples and posts and the AN001 so I can learn more about the counters. How many years have I been using the chip I haven't done counters yet? There is no excuse.
Anyway, I looked at page seven of AN001 and tried implementing it in assembly. The pin for the back light is passed to the routine so I can't declare it in the defined data of the DAT section like you did.
Here is what I have. blPin is brought over from copying in parameters. blPin is the pin value, not the pin mask. Prior to this piece of code the pins are set to outputs or inputs.
In the command section of the code I have this.
paramA would range from 0 to 100. So far I think something is wrong. When the code is run and paramA is 0, the LED is on. When paramA is 100 the LED is on and the same intensity. To be sure it was not the passing of paramA I replaced it with #0 and #100 and the LED is still on in both cases. I was expecting that with #0 the LED would be off and #100 the LED would be full on.
Perhaps clarifying what I am doing in my code can help anita1984 too for an example of what to put in his code. I am trying to set the counter to PWM the LED to a certain intensity. My goal is to set the counter, leave and forget about it unless the intensity needs to change.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, uOLED-IOC, eProto fo SunSPOT, BitScope
www.tdswieter.com
I still don't understand the posted example you made Paul. Should the waitcnt and duty be in the code?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, uOLED-IOC, eProto for SunSPOT, BitScope
www.tdswieter.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Timothy D. Swieter, E.I.
www.brilldea.com - Prop Blade, LED Painter, RGB LEDs, uOLED-IOC, eProto for SunSPOT, BitScope
www.tdswieter.com