RC input

bluejets

Senior Member
Where would I find information on minus step values and how to implement??
Trying to use rc input to generate a 3.3 volt output from the neutral position of the throttle stick in both directions. i.e. zero to 3.3 forward and zero to 3.3 reverse.
I have the first bit (iI think) but need to find info on minus stepping.
 

MPep

Senior Member
In the orange bar above, look for FAQ. At the bottom of that page is where the answers are!! :D
 

MartinM57

Moderator
Just type this exactly, but without the space characters after the [ and before the ]

[ code ]
high 1
[ /code ]

and you will end up with

Code:
high 1
 

bluejets

Senior Member
Thanks Martin,
With reference to the original question, I think I may have sorted it out for myself. Anyone welcome to take a look and comment. Thanks.....
Code:
Main:
	pulsin 4,1,b0					'read rc signal 
	sertxd("RC input value  ",#b0,13,10)		'output to serial monitor
	if b0>150 then forw				'forward speed
	if b0<150 then revse				

forw:
	b1=b0-150						'b1 is forward speed percentage
	b1=b1*132/100					'b1 set at 66% of max(3.3volts at 5 volt supply)
	pwmout 2,100,b1					'output this voltage and use at input to sound chip
	sertxd("forward percent is ",#b1,13,10)					
	goto main
revse:
	if b0<100 then goto main			'no signal
	b2=150-b0						'b2 is reverse speed percentage
	b2=b2*132/100					'b2 set at 66% of max(3.3volts at 5volt supply)
	pwmout 2,100,b2					'output this voltage and use as input to sound chip
	sertxd("reverse percent is ",#b2,13,10)
	goto main
 

hippy

Ex-Staff (retired)
Where would I find information on minus step values and how to implement??
Trying to use rc input to generate a 3.3 volt output from the neutral position of the throttle stick in both directions. i.e. zero to 3.3 forward and zero to 3.3 reverse.
I have the first bit (iI think) but need to find info on minus stepping.
I think you'll need to explain exactly what you mean by "minus stepping" and what that translates to in electrical and control terms.

A circuit diagram would help, or details of what components / motor driver you are controlling and what inputs that expects.
 

bluejets

Senior Member
I have at different times, seen reference in here to "step -1" but I cannot find it in tutorials anywhere and not sure how to implement it in code anywhere.
I have found that trying to do a "search" can take one on a round trip that can take days before one finds anything remotely like what the search is about.
Turns out I have ended up approching the problem from a different angle and do not need this but I would still like to know for future reference.
I have included a layout of what I am trying to get to with the above code as you suggested.
Thanks....
 

Attachments

hippy

Ex-Staff (retired)
"STEP" and "STEP -1" relate to adjusting the control variable in a FOR-NEXT loop. SEe PICAXE Manual 2 "Basic Commands" for further details.
 

Paix

Senior Member
Contrasting the two forms, the step can be greater than 1
Code:
; [B]Positive stepping example[/B]
main:
    [B]for b0 = 1 to 20[/B]     ; define loop for 20 times, stepping positively (counting up)
                         ; can also be expressed as [B][COLOR="Red"]for b0 = 1 to 20 step 1[/COLOR][/B]
    if pinC.1 = 1 then exit

    high B.1 ; switch on output B.1
    pause 500 ; wait 0.5 seconds
    low B.1 ; switch off output B.1
    pause 500 ; wait 0.5 seconds
    [B]next b0[/B] ; end of loop

pause 2000 ; wait for 2 seconds
goto main ; loop back to start
Code:
; [B]Negative stepping example[/B]
main:
    [B]for b0 = 20 to 1 step -1[/B]     ; define loop for 20 times, stepping negatively (counting down)
    if pinC.1 = 1 then exit

    high B.1 ; switch on output B.1
    pause 500 ; wait 0.5 seconds
    low B.1 ; switch off output B.1
    pause 500 ; wait 0.5 seconds
    [B]next b0[/B] ; end of loop

pause 2000 ; wait for 2 seconds
goto main ; loop back to start
I hope that this helps somewhat.
 
Top