hello everyone,how can you eliminate/improve the inaccuracy of time durations (PAUSES) using the "pauseus" command in PICAXE?

Con-voy

New Member
I need to realize a sequence of pulses with a duration of 100,200,300...microseconds and I find that I do not succeed with these microcontrollers.

Respectfully
 

papaof2

Senior Member
That's one downside of having a BASIC interpreter in the chip - it's not blindingly fast. There may be some workarounds - the folks here have squeezed most of the secrets out of the PICAXE chips but you'll need to wait for those who check for new messages in the evening, UK time.
 

AllyCat

Senior Member
Hi,

You should be able to generate pulses accurate to about +/-1% with for example PULSOUT pin , 10 for 100us, etc. (i.e. in increments of 10us). BUT, the gap between pulses (from consecutive instructions) will be about 700 microseconds because of the decode/execution time of the interpreted Basic language. You could improve this by using a SETFREQ M32 and then PULSOUT pin , 80 for 100us, etc.. which will reduce the gap between pulses to about 90 us (for consecutive instructions).

If you want to control "High" and "Low" pulse periods at the same time then you can use PAUSEUS 1 which executes in a very similar time to PULSOUT pin , 1. Thus you could try : SETFREQ M32 : HIGH pin : PAUSEUS 1 : LOW pin : PAUSEUS 81 : HIGH pin , etc.. That will probably give a High pulse of slightly over 100 us and a Low period which is about 100 us longer than the pulse (adjustable in 1.25 us increments). However, any program loops (e.g. FOR .... NEXT , DO .... LOOP UNTIL .. , etc.) will add their own delays of around 2 ms at 4 MHz (or a simple GOTO .. adds around 1 ms).

Alternatively, for an accurate, repeating pulse waveform you could use the (H)PWMOUT commands, for example PWMOUT pin , 49 , 100 should give quite accurate 100 us pulses spaced by 100 us. Then the pulse widths could be updated "on the fly" by issuing a new command such as PWMOUT pin , 99 , 200 or sometimes better with PWMDUTY ... and again you can increase/decrease the resolution with SETFREQ .. command and/or the PWMDIVn constants.

Note that most of these commands (except the PWMDIVn qualifier) can use PICaxe variables, so commands such as PAUSEUS w1 or even PWMOUT b0 , b1 , w1 can be valid commands (provided that the variables are set correctly).

Cheers, Alan.
 
Last edited:

Flenser

Senior Member
I think that we need more information about what you are trying to do.

a sequence of pulses with a duration of 100,200,300...microseconds
It's not clear to me exaclty what you want to do.
For example, is all you want to do send pulse 100ms, pulse 200ms, pulse300ms, pulse 100ms, pulse 200ms, pulse300ms and repeat forever or is what you want to do more complex?

I find that I do not succeed
How did you try to create your sequence of pulses and what was wrong with the result?

If you will post the program you wrote then that will help us understand what you are trying to do and it could help us suggest a way to change your program so that it better succeeds.
 

Con-voy

New Member
Hi,
First of all, I want to thank everyone who answered my message.
In the second line, I will briefly explain what I want to do.
About 30 years ago, I underwent a surgical operation for a herniated disc, an operation that was successful and since then I have been concerned with building a device to generate some forms of therapeutic currents for electrotherapy, mainly trains of rectangular pulses, with various frequencies and duration of approx. 125-400 microseconds / with pauses also in microseconds or milliseconds.
In Romania, there is a saying/joke (maybe a bit macabre); ...the operation was successful, but the patient is dead.... This is not my case. After the operation, some secondary problems remained solved, if I can call them that: back pain, pain in the lower/upper limbs and others .To alleviate these discomforts I need this device. In recent years, I have studied the relevant medical documentation in this field and I have experimented with various simpler setups/apparatus for these treatments. I know where to start and where to go.
By chance I discovered these PICAXE microcontrollers and a light bulb went off in my head. With these circuits I can fulfill my wish. The problem arose when I noticed that the programmed time durations in microseconds are totally different from those achieved by this chip (much higher).
I would like to clarify that I am experimenting with making this montage with a PICAXE 40X2 type chip, using the internal clock.

In the following days, I will send you more information and the program I used.
I wish you a happy new year.
Happy Birthday.
 
Top