Shop OBEX P1 Docs P2 Docs Learn Events
MS5607 Sensor and Controlling DC Motor — Parallax Forums

MS5607 Sensor and Controlling DC Motor

rhampto1rhampto1 Posts: 2
edited 2013-04-30 12:15 in General Discussion
I've got the Board of Education with the MS5607 altimeter module and LCD display. The code for it is working great and it performs well, however, I would like to use pulse width modulation to control a motor as well based on the feedback from the sensor. Something such as if altitude is 7200 then the DC motor is at 100% but when it reaches 7250 it goes to 50%...Does anybody have a general idea about how to go about this? New to the Propeller scene. Thanks in advance.

Comments

  • SRLMSRLM Posts: 5,045
    edited 2013-04-25 14:18
    You should use a PWM object. If you go to Obex and look under motor control there are several options. This one would be a good place to start:

    http://obex.parallax.com/object/481
  • rhampto1rhampto1 Posts: 2
    edited 2013-04-26 11:58
    Yeah,

    No luck with that....trying to trouble shoot my if statement first by making the lcd play a tone based on the if statement and I can't get that to work either. It is listed below:

    OBJ
    display : "FullDuplexSerial.spin"
    alt : "29124_altimeter"
    number : "FloatString"

    CON
    _clkmode = xtal1 + pll16x ' Sets frequency
    _xinfreq = 5_000_000 '
    TX_PIN = 2 'Sets pin for Rx communictation with LCD
    BAUD = 19_200
    START_ALT = 7200 ' Enters a reference elevation for the pressure to be calibrated off of.


    PUB start | a, t, altitude 'Sets a,t,altitude as variables
    display.start(TX_PIN, TX_PIN, %1000, 19_200) ' Start Parallax FullDuplexSerial.
    waitcnt(clkfreq / 100 + cnt) ' Pause for FullDuplexSerial.spin to initialize
    display.tx(17) ' Turn on display backlight
    alt.start(alt#QUICKSTART, alt#BACKGROUND) ' Start altimeter for QuickStart with background processing.
    alt.set_resolution(alt#HIGHEST) ' Set to highest resolution.
    alt.set_altitude(alt.m_from_ft(START_ALT * 100)) ' Set the starting altitude, based on average local pressure.
    repeat
    a := alt.altitude(alt.average_press) ' Get the current altitude in cm, from new average local pressure.
    display.str(string("Alt:")) ' Print header Altitude:....
    display.str(alt.formatn(a, alt#TO_FEET,8)) ' Print altitude in feet
    t := alt.current_temp ' Get the current temperature.
    display.str(string("Temp:")) ' Print header Temp:.....
    display.str(alt.formatn(t, alt#TO_DEGF,8)) ' Print temperature in Farenheit
    display.tx(13) ' Line feed

    repeat
    altitude:=number.FloatToString(alt#TO_FEET)
    if altitude>7201
    display.tx(212)
    display.tx(220)
  • SRLMSRLM Posts: 5,045
    edited 2013-04-30 12:15
    You'll need to post your code with the [ code ] tags (without the space) to preserve the formatting. For example:
    repeat
    	debug.str(string("Hello, World!"))
    
Sign In or Register to comment.