ASDevaraju

Combining codes of Ping))) Sensor and Servo connected to Propeller Board inside S2

Rate this Entry
Quote Originally Posted by ASDevaraju View Post
Hi, I am currently working an S2 robot with a Propeller Board inside(I remember it being a Propeller BOE). The external hardware added to the robot are the PING))) Ultrasonic Sensor and the Servo(Parallax Standard Servo). I am currently stuck on programming both the sensor and the servo to work at the same time. Here are the codes for the Ping))), The servo, and for the final code, respectively: PING_TEST: CON
_xinfreq = 5_000_000
_clkmode = xtal1 + pll16x

PING_PIN = 5
PCBAUD = 115_200
obj
d : "Parallax Serial Terminal"
ping : "Ping"
PUB Go
d.start(PCBAUD)
repeat
d.home
d.str(string("Ping distance: "))
d.dec(ping.Millimeters(PING_PIN))
d.str(string(" mm "))
PauseMs(20)
pub PauseMs(duration)
waitcnt(cnt + (clkfreq/1000)*duration)

S2_SERVO_TEST: con
_xinfreq = 5_000_000
_clkmode = xtal1 + pll16x
SERVO_PIN = 4
pub RunServo
'set pin to be an output
dira[SERVO_PIN]~~
repeat
PulseOut(1000, SERVO_PIN)

PulseOut(1500, SERVO_PIN)

PulseOut(2000, SERVO_PIN)

pub PulseOut(time, pin)
repeat 100
outa[pin]~~
waitcnt(cnt + (clkfreq/1_000_000)*time)
outa[pin]~
PauseMs(20)
pub PauseMs(duration)
waitcnt(cnt + (clkfreq/1000)*duration)

And the PING_SERVO: CON
_xinfreq = 5_000_000
_clkmode = xtal1 + pll16x

PING_PIN = 5
PCBAUD = 115_200
SERVO_PIN = 4
obj
d : "Parallax Serial Terminal"
ping : "Ping"
PUB Go
d.start(PCBAUD)
repeat
d.home
d.str(string("Ping distance: "))
d.dec(ping.Millimeters(PING_PIN))
d.str(string(" mm "))
PauseMs(20)
pub RunServo
'set pin to be an output
dira[SERVO_PIN]~~
repeat
PulseOut(1000, SERVO_PIN)

PulseOut(1500, SERVO_PIN)

PulseOut(2000, SERVO_PIN)

pub PulseOut(time, pin)
repeat 100
outa[pin]~~
waitcnt(cnt + (clkfreq/1_000_000)*time)
outa[pin]~
PauseMs(20)
pub PauseMs(duration)
waitcnt(cnt + (clkfreq/1000)*duration)
My classmate told that the main issue is the PulseOut function, but I am still unsure.

Submit "Combining codes of Ping))) Sensor and Servo connected to Propeller Board inside S2" to Digg Submit "Combining codes of Ping))) Sensor and Servo connected to Propeller Board inside S2" to del.icio.us Submit "Combining codes of Ping))) Sensor and Servo connected to Propeller Board inside S2" to StumbleUpon Submit "Combining codes of Ping))) Sensor and Servo connected to Propeller Board inside S2" to Google

Categories
Propeller , ‎ Programming , ‎ Robotics , ‎ Engineering

Comments

  1. davejames's Avatar
    ASDevaraju - this is a "double post" which is a Forum No-No.

    Please consider deleting it and staying with the original in the Prop1 forum.

    Thanks.