Hi, I'm using readad from a pot and scale to change pulseout and display the value.
I noticed the servo actuator didn't rotate more than 100 degrees so scoped the period and it's not the value used. pulse_out is the value. duff nano?
~~~
adc_val=ReadAD(portc.0)
pulse_out=scale(255-adc_val,0,255,75,225) ;scale readad to pulse_out
GLCDprint 140,154,str(pulse_out)+" ",ili9341_white
newval = Scale(adc_val,0,255, 45, 314) ;scale ReadAD to gauge
if newval <> oldval then
erase_needle
draw_needle
oldval=newval
end if
pulseout portd.7,pulse_out 10us ;must out to servo every 20 ms
~~~
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'll change the nano and try on 2 unos. Never had this prob before. The pulse_out is displayed as text then used with pulseout so why would pulseout not give right result? lots of testing. I'll get back. Thanks.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am guessing this is an ATMEL chip. Because of the last post not the first post. I like a guessing game.
Help me understand where in the Help does is say =ReadAD(portc.0) where the parameter is a port address? Typically, you would be using an ANX so, something like =ReadAD(AN0)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
ok.changed to adc_val=ReadAD(an0). no difference to using port name.
more basic testing needed. new prob to me using avr. The fact running off usb the 5V pin is not at 5V.
Last edit: stan cartwright 2018-02-23
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My error. I clicked period on scope not +Pulse Width. It is correct.
The metal gear fake mg90s servo was faulty (I bought 5). Replacing it and all is fine.
The lesson is don't assume stuff from China works and it's a program fault :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I'm using readad from a pot and scale to change pulseout and display the value.
I noticed the servo actuator didn't rotate more than 100 degrees so scoped the period and it's not the value used. pulse_out is the value. duff nano?
~~~
adc_val=ReadAD(portc.0)
pulse_out=scale(255-adc_val,0,255,75,225) ;scale readad to pulse_out
GLCDprint 140,154,str(pulse_out)+" ",ili9341_white
newval = Scale(adc_val,0,255, 45, 314) ;scale ReadAD to gauge
if newval <> oldval then
erase_needle
draw_needle
oldval=newval
end if
pulseout portd.7,pulse_out 10us ;must out to servo every 20 ms
~~~
Is the related to your post of the strange ADC readings? I think so. Simplify your code. Examine the ADC reading.
I'll change the nano and try on 2 unos. Never had this prob before. The pulse_out is displayed as text then used with pulseout so why would pulseout not give right result? lots of testing. I'll get back. Thanks.
I am guessing this is an ATMEL chip. Because of the last post not the first post. I like a guessing game.
Help me understand where in the Help does is say
=ReadAD(portc.0)
where the parameter is a port address? Typically, you would be using anANX
so, something like=ReadAD(AN0)
ok.changed to adc_val=ReadAD(an0). no difference to using port name.
more basic testing needed. new prob to me using avr. The fact running off usb the 5V pin is not at 5V.
Last edit: stan cartwright 2018-02-23
I asked previously. What are the adc values ? The rawvalue range before scale(). Is this OK?
My error. I clicked period on scope not +Pulse Width. It is correct.
The metal gear fake mg90s servo was faulty (I bought 5). Replacing it and all is fine.
The lesson is don't assume stuff from China works and it's a program fault :)
OK