Discussion forum for the BasicX family of microcontroller chips.
Hi~ I am new in BX24, my problem is shown below Do call control() 'a control function delay(2.5e-4) loop I want the loop's freq is 4000Hz, but the min. time of delay should be 1.95ms, so is that loop work? or any other suggestion? Tahnks a lot Owen
FYI - If you have a time delay of 1.95ms then max loop freq is aprox. 500 hz or less. You should also consider the time of the called functions in your loop when calculating your total loop time, not just the delay function. What frequency did you get when you tried it out? rr --- In basicx@basi..., letter2email@... wrote: > > Hi~ > > I am new in BX24, my problem is shown below > > Do > call control() 'a control function > delay(2.5e-4) > loop > > I want the loop's freq is 4000Hz, but the min. time of delay > should be 1.95ms, so is that loop work? or any other suggestion? > > Tahnks a lot > Owen >
I have tried the following method to detect the loop freq
Do
call control() 'a control function
putpin(14,1)
putpin(14,0)
delay(2.5e-4)
loop
I observed the pin and calucated the freq which it is very high that out of my
expectation.
Actually I need to write two tasks to control, using PID, the motor rotational
angle, one is current control task with loop freq 4000Hz, and the other is angle control
task with loop freq 2000Hz. Do you have any suggestion to fix the loop freq about
2000Hz~4000Hz
Thanks
Owen
raunig2003 <raunig2003@raun...> 說: FYI - If you have a time delay of
1.95ms then max loop freq is aprox.
500 hz or less.
You should also consider the time of the called functions in your
loop when calculating your total loop time, not just the delay
function.
What frequency did you get when you tried it out?
rr
--- In basicx@basi..., letter2email@... wrote:
>
> Hi~
>
> I am new in BX24, my problem is shown below
>
> Do
> call control() 'a control function
> delay(2.5e-4)
> loop
>
> I want the loop's freq is 4000Hz, but the min. time of delay
> should be 1.95ms, so is that loop work? or any other suggestion?
>
> Tahnks a lot
> Owen
>
SPONSORED LINKS
Microcontrollers
Microprocessor Intel
microprocessors
Pic microcontrollers
---------------------------------
YAHOO! GROUPS LINKS
---------------------------------
_______________________________________
YM - 離線訊息
就算你沒有上網,你的朋友仍可以留下訊息給你,當你上網時就能立即看到,任何說話都冇走失。
http://messenger.yahoo.com.hk
[Non-text portions of this message have been removed]
> Do > call control() 'a control function > putpin(14,1) > putpin(14,0) > delay(2.5e-4) > loop > > I observed the pin and calculated the freq which [] is very high, [beyond] my expectation. [My translation] If you need to run your control loop at 4KHz, I suggest that the BX-24p is not the machine for you. The machine can achieve that loop rate with only minimal processing in the loop. I don't understand how you could have measured a high frequency on the pin. The fastest loop that toggles a pin might be: do call putpin(14, 1) call putpin(14, 0) loop On a BX-24p, that code will generate a ~9.6KHz signal. If you add a Call Delay() of any period greater than zero, you will introduce a minimum two-tick pause per loop, reducing your loop rate to ~256Hz - if whatever time your control function uses is disregarded - or less, if it is considered. Sleep will be little more useful, introducing either ~zero or a minimum one-tick pause, still far too large. Another delay mechanism is available in PulseOut using a dummy pin, and it offers much better resolution: do call putpin(14, 1) call putpin(14, 0) call PulseOut(0, 0.0001, 0) loop will loop at ~4.056KHz, for example. Still, this is not a good way to pace a fast sample or control loop, I think. I believe you'll do better with an external interrupt - which you can generate with Timer1 or Timer2, connecting pin 26 or pin 25, respectively, to the interrupt pin 11. Keep your processing efficient and minimal, or you will will not be able to maintain a rate you'd like. Tom
Thanks you for your suggestion~ []______________________________