Menu

pulseout wrong

Help
2018-02-23
2018-02-24
  • stan cartwright

    stan cartwright - 2018-02-23

    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
    ~~~

     
  • Anobium

    Anobium - 2018-02-23

    Is the related to your post of the strange ADC readings? I think so. Simplify your code. Examine the ADC reading.

     
  • stan cartwright

    stan cartwright - 2018-02-23

    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.

     
  • Anobium

    Anobium - 2018-02-23

    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)

     
  • stan cartwright

    stan cartwright - 2018-02-23

    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
    • Anobium

      Anobium - 2018-02-23

      I asked previously. What are the adc values ? The rawvalue range before scale(). Is this OK?

       
  • stan cartwright

    stan cartwright - 2018-02-24

    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 :)

     
    • Anobium

      Anobium - 2018-02-24

      OK

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.