PDA

View Full Version : RCTIME and PAUSE duration (giving "pause duration" a broader range)



TonyA
08-08-2005, 10:59 PM
Hi,

I am using this to adjust pause duration:

HIGH 14
PAUSE 1
RCTIME 14, 1, pause_result
rhythm = pause_result / 6
PAUSE rhythm

I'm using the above to read a 10 kOhm pot with a 0.1 cap. I get a range from 1-652.

I am wondering if it is possible to get a broader range, like from -10 to 1000.

My goal is to make the "rhythm" have a range that is much slower and much faster than what I am currently getting.

Thanks for any help,

Tony

Yanroy
08-08-2005, 11:06 PM
A negative pause?· I'd like to see that happen...

As for getting a bigger value out of RCTIME, I believe you can add a bigger resistor for the cap to discharge through, which will take more time.· Or perhaps even a bigger cap would work, to a point.· Keep in mind that RCTIME has some upper limit... I don't recall what it is.· Probably a WORD's worth.

Jon Williams
08-08-2005, 11:09 PM
Yes, it just takes a little math.· Your current span is 651 (652 - 1)·and you want to increase that to 990 (1000 - 10).· So if you divide 990 by 651 you get 1.52.· Don't panic, you can use the */ operator to multiply by fractional values.· Take the 1.52 and multiply that by 256; you get·389.· Now you can apply that value like this:

· rhythm = pauseResult */ 389 + 9

Note the + 9 is required to meet your bottom end requirement (1 x 1.5 will be 1.5 and get truncated to 1, so adding 9 gets you to 10).

If verified the equation with a simple test loop:

· FOR result = 1 TO 652
··· rhythm = result */ 389 + 9
··· DEBUG DEC result, TAB, DEC rhythm, CR
· NEXT

And found that the output was 10 (when result is 1) to 999 (when result is 652).

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

TonyA
08-08-2005, 11:12 PM
Could you damage the stamp if you go too low on the values of the pot and cap?

I was able to slow it down to a good value, speeding it up is now what I need.

Thanks for your help,

Tony

Jon Williams
08-08-2005, 11:16 PM
Since the pin that is used for RCTIME is set high to charge the capacitor, you don't want that to connect directly to ground -- this is why we recommend putting a 220 inline with the pin.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

TonyA
08-08-2005, 11:51 PM
I tried:

HIGH 14
PAUSE 1
RCTIME 14, 1, pause_result
rhythm = pause_result */ 389 + 9
PAUSE rhythm

But I don't get any change in the ryhthm. I even tried varying the numbers, no change.

I have been able to slow it down by doing this:

HIGH 14
PAUSE 1
RCTIME 14, 1, pause_result
rhythm = pause_result
PAUSE rhythm * 6
DEBUG "pause time = ", DEC5 pause_result, " ", CR

This produces a nice slow beat. Now I need to retain this slow pause duration (slow beat when "pause duration = 652), while getting it to go faster on the other end (when pause time = 1)

(I apologize if I don't know what I'm saying, but I do actually learn this way, and it's a lot of fun)
Learning = more Stamps = higher Parallax profits = possible salary raise... <---joking

Thanks again,
Tony

Post Edited (TonyA) : 8/8/2005 4:55:34 PM GMT

TonyA
08-09-2005, 12:20 AM
I changed my variable "pause_result" to a Word (from a Byte) and that made a change in slowing the duration even more, but made no change in getting more speed.

HIGH 14
PAUSE 1
RCTIME 14, 1, pause_result
rhythm = pause_result
PAUSE rhythm * 4
DEBUG "pause time = ", DEC5 pause_result, " ", CR

For some reason PAUSE rhythm * 4 worked better in getting a slower PAUSE duration than rhythm = pause_result */ 389 + 9

Jon Williams
08-09-2005, 12:24 AM
You can reverse the way the pot works like this:

· result = 652 - result
· IF (result.BIT15 = 1) THEN result = 0

The second line is required in case the result exceeds what you expect (this can happen with component variations).· That line checks BIT15 of result which will be 1 if the value is negative; when that happens IF-THEN corrects it to zero.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

Jon Williams
08-09-2005, 12:25 AM
TonyA said...

For some reason PAUSE rhythm * 4 worked better in getting a slower PAUSE duration than rhythm = pause_result */ 389 + 9

Take a look what's happening ... if your pause result is 652 then multiplying it by 4 gives you 2608 -- the other equation only gives you 1000, which is what you specified in your request.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

TonyA
08-09-2005, 12:33 AM
Yes, that reversed the pot. But I still can't speed up the PAUSE duration beyound a certain speed. I was only able to slow it using

HIGH 14
PAUSE 1
RCTIME 14, 1, pause_result
rhythm = pause_result
PAUSE rhythm * 4
DEBUG "pause time = ", DEC5 pause_result, " ", CR

Do you think there is some other math that would speed up the PAUSE duration? Or maybe the use of a smaller value pot (like 5 k Ohms). I did try a smaller value cap, no change.

Jon Williams
08-09-2005, 12:36 AM
There is going to be a certain speed threshold you'll hit -- even with a PAUSE 0 you'd have a delay between notes due to the execution time of other program instructions.· Using the equation worked out above is the best way to expand your span and keep the low and high ends intact.· By multiplying, you always expand your low end value.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

TonyA
08-09-2005, 12:48 AM
Yes, I see.

Would it be possible to use 2 instances of the RCTIME and Pause duration (using two pots) to modify the pause duration.
(Like two beats ocurring at the same time.) Or will the BS2 only execute one instance?

' Instance 1
HIGH 14
PAUSE 1
RCTIME 14, 1, pause_result
rhythm = pause_result
PAUSE rhythm * 4

' Instance 2
HIGH 13
PAUSE 1
RCTIME 13, 1, pause_result2
rhythm2 = pause_result2
PAUSE rhythm2 * 4

(I'm just experimenting out loud, sorry)

Tony

Jon Williams
08-09-2005, 02:13 AM
You can only do one thing at a time. To measure two pots at once I would go to the ADC0832. The result from the ADC0832 will be 0 - 255 (full scale), so you'd have to change your math a bit.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax

TonyA
08-09-2005, 02:56 AM
Ok, thanks.


Is there anything else you can do with rctime and Pause to make things more interesting in this way? (Any referrences to literarure or anything online would be appreciated). Thanks again.

Tony