I have a ultra sonic sensor that isn’t made by vex and I want to use it with the vex v.5 microcontroler. It has a 3 wire pwm output and I need to know if I simply plug it in and it will work or if it requires a custom code in easy c.
Any answers or suggestions would be greatly appreciated.
Posting the part number and source of it would be an excellent start,
since my first guess is that the sensor output is not PWM (pulse width modulation), but merely has 3 wires with the same connector.
If you look at the Vex ultra sound sensor and documentation, it has two 3wire connectors, one is connected to a digital output (it looks like) to send a ping, the other is connected to a digital interrupt input which uses software to check the time delay between launch and return to calculate the distance.
Without similar basic documentation eqv to that provided on the Vex site, your sensor is useless. If you have no documentation, the first step is to find or figure out some.
If it has only 3 wires, they must be power,ground,signal.
If there are separate power and ground, then the 3 wires could be gndref, sig1, sig2. In the unlikely event the two signals match the Vex signal protocol, all you need is the correct y splitter to match the vex inputs.
If it is a smart sensor with an I2C or I2S or other serial interface, it gets more complicated, but similar things have been reported as successfully completed here in the past by quazar and MarkO.
Lots of data there at parallax. It is a single signal pin for both input trigger and output pulse width measurement. I don’t know if Vex can do that. It might be easier/required to connect the signal pin to both an input and an output port of Vex, so that the output can trigger the pulse start, and the input can read the return pulse width. If the Vex pinger uses the same pwm protocol, then you may be able to use the existing Vex Easy C routines, rather than have to write new ones following the Basic examples.
Another issue: This ping requires 5v. I don’t know what Vex supplies at the for power at the digital IO ports, 5V or Vbat or what.
Thanks for the pointer. Keep us post on your progress.
yeah i know its complicated i think i should just get a vex one to simplify things.
the one thing i was hoping to learn from this was the incorporation of non vex sensors in the vex micro controller.do you think it would be safe to just plug it in and do a print to screen function but program it with mplabs or robot c and write my own code/protocol for it.
oh and i looked it up and from what i understand the vex micro controller provides 5v which from what i learned is standard for all digital inputs. ( 5v is “high” and below that is “low”)
If you match up the 5v, gnd, and signal, it should be relatively safe.
Unless you can change IO direction on the fly, You’ll need to use two digital IO ports, one set to output to start conversion, one set to input to read the conversion results. Note that the output results will also be an input, and start another conversion.
Well, not exactly. Here is some additional background, since you seem interesting in learning. 4.9v < 5v but won’t to be read as “low”. There is a pullup resistor on the digital input, so an unconnected pin is read as 1, and if you connect a limit switch that shorts the input to Gnd, it is read as 0. There will be some threshold between 5v and 0v to determine 1 or 0 inputs. Common values for the threshold are 1.5v, or 1/3 of 5v = 1.7v, or 1/2 of 5v =2.5v. 5v TTL spec uses < 0.8v for low and > 2v for high.