How would I say this.?.
bobsmith
Posts: 36
I am programming code for a paintball· marker.· What i want the code to be like is·
each time the microswitch is activated that equal 1.3 times the solenoid is cycled but it only cycles once b/c 1.3 isn't a integer.· But say the microswitch is activated 5 times in a row it times those 5 activations by 1.3 which equals 6.5 but it only cycles the solenoid 6 times b/c 6.5 isn't an integer
each time the microswitch is activated that equal 1.3 times the solenoid is cycled but it only cycles once b/c 1.3 isn't a integer.· But say the microswitch is activated 5 times in a row it times those 5 activations by 1.3 which equals 6.5 but it only cycles the solenoid 6 times b/c 6.5 isn't an integer
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
I don't think the user can pull the trigger faster than every 100 mSec -- but maybe that's not your problem?
The statement "each time the microswitch is activated that equal 1.3 times the solenoid" doesn't make sense to me. You need to put in some more words -- like "equal 1.3 times the length of time the solenoid is active" or something like that.
The way you've stated the problem so far, it is very hard to see what you are asking.
SYMBOL trigger = 1
SYMBOL solenoid = 2
if trigger = 1 then
high solenoid
pause 40
low solenoid
pause 40
end
but I want it to say:
____________________________________
if trigger is pulled then
cycle soleniod 1.3 times each time the trigger is pulled, but only cycle the integer part of the digit.
______________________________________________
Example:
If trigger is pulled 6 times in a row
then the solenoid cycles 7 times
(6 * 1.3 = 7.8 but we make 7.8 be 7)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
If you multiply your factor (1.3) by 10 then use it in your existing equation:
······················ 6 * (10 * 1.3)· or· 6 * 13·
and then divide your answer by 10 as shown below:
····················· ·cycle = 6 x 13 : cycle = cycle / 10
the decimal part of the answer will be dropped which·appears like what you want it to do, but you·WILL realize the mathematical effect of the .3 value, which is also what it seems like you want to do. This is just the natural effect of the PBASIC "rounding" to an integer value. In effect you are scaling up the interim answer in the first part, and then scaling back down in the second part.
Regards,
Bruce Bates