You should be able to use 5V analog sensors with the 3-wire ports.
As @John_TYler said, the easiest way to interface with V5 would be to get sensors that output analog values in the first place. V5 was not designed to be an open system with native support for Serial or I2C interfaces (that are supported by Cortex).
However, if you have to use I2C sensors you could do that through an I2C enabled board like Arduino. Depending on how much and what type of information you need to communicate to the V5 robot, you have multiple options.
If you just need to send a simple Yes/No bit to the robot, based on the sensor crossing some threshold value, then you can wire one of the digital Arduino output pins to one of the V5 3-wire ports that will let you read 0 or 1 value.
If you need to communicate a range of values back to V5, then you could connect a small capacitor to one of the Arduino PWM output pins and use it as an analog input on one of the V5 3-wire ports.
If you want to send back digital data you could setup two digital pins as low speed bit-bang serial interface between Arduino and V5. As long as it allows > 15-20 ms time between consecutive bits you should be able to do that.
Finally, if you need to send high speed high volume data you could use RS485 or USB interfaces of V5, but that is not a simple task:
Ok I can try that.
So if I use something like this one, I can wire it directly?
but requires careful timing to grab data
Just so we have an example. This would work and could be wired directly as an analog device with a V5.
What you linked would require an arduino, maybe a vex cortex could do it? A V5 definitely couldn’t. Then you would need to get the data from the arduino/cortex to a V5, somehow.
25-80us bit timing is well below the 10ms minimum delay that legacy port co-processor has in communicating with V5 main processor.
@MiPlayer123, can you tell us more about what you need to build at the end?
There are options to drive VEX based robot without the need V5 or even Cortex. For example, we built several robots where we could drive legacy 393 motors directly with Arduino or ESP8266 boards: Inexpensive control system for teams without access to Cortex / V5 off-season
My goal at the end of this is to create a robot that drives to a specific location using the vision sensor. Then it will gather humidity (and maybe temperature) and air quality data. If the values seem okay, it will move to another location. If not then the robot will stay there and filter/ humidify the air.
Also wondering, can I use SPI sensor with the V5?
Not in a straight forward way.
Short answer is no. Neither Cortex nor V5 do not expose SPI interface to the end user. (SD card interface, probably, uses some variant of SPI, but V5 firmware wouldn’t let you use it for arbitrary sensors.)
You will still need to connect any SPI or I2C sensors to another board.
I would suggest you to get an Arduino nano or mini. Use it to read and filter sensor data, and then relay it slowly to V5 brain using a protocol similar to DHT11/22 linked above but at much slower rate. This way you could reuse DHT library code with minor modifications to make it about 1000 times slower to work with V5.
That’s interesting. Are you doing it as an educational exercise?
Because, I would imagine that if you had to dehumidify the area for real on a scale where DHT11 could pick the changes with its +/-5% accuracy, you would need to carry a commercial scale dehumidifier that would require power supply that is well beyond V5 capabilities.
I am doing it for fun and to learn. I am planning to use battery powered purifiers/ humidifiers.
So, if I use an Arduino, I have all my sensors and use them to gather the data, then I can use the output on an Arduino to output the data digital or analog to a 3 wire port (what wiring?). I then can use sensor.get_value() to get the data on the robot side.
Is this correct or is there anything I am missing.
To run the input to a analog port you would need something like this. A DAC which would let the arduino output analog values to the V5.
What @technik3k suggested was to very slowly with digital pin send values from the arduino and the v5. 1 bit every 10ms of communication in some cases is totally enough. ( you can get some speedup by using multiple pins at a time)
So would you hook this up to the Arduino and use the output on this module to the v5 and input from the Arduino?
What @technik3k said, I output on an Arduino to output the data digitally as a DHT11 and use the 3-wire port on the v5 to receive the data, connecting 5V and ground?
Ya with a DAC module like that, you would have
Sensor - > arduino - > DAC board - > v5
Without it would be,
Sensor - > arduino - > v5
Probably like 20x slower communication.
It would only be slower directly, but how slow.
Also do I need to do anything extra other than use output every 10ms to the V5 and get digital?
Do I need a separate output for each sensor, or can I use one?
Can I use this:
It says: Digital I/O Pins 14 (of which 6 provide PWM output), so I can use these as my output, right?
So the speed is going to depend on you. You have implement some way of communicating the data. Seems the sensor has 4 bytes of data (2 bytes for each temp + humidity) you could reduce this by lowering resolution or lowering precision.
So 32 bits would take 320ms best case, let’s assume another 50% of overhead and we get around 500ms. You could of course make all this parallelized if you wanted so let’s say
500ms / number of ports you dedicate to it.
If you wanted a more robust communication it would be longer but that’s probably fine.
So in the real world scenario we have to do stuff like this to have Allen Bradley talk to Fanuc Robots, what we do is have:
Sensors (1,2,3,…) —> PLC (Or arduino in this case) —> DAC (We call them Amp Cards) —> Fanuc Cell
@tabor473 Had this perfectly correct with his.
What we do is have the secondary brain (Arduino) Collect all your data and then send one output
signal when all the conditions are made. If the Fanuc Cell does not get a packet within certain amount of time it will move to certain stage telling the brain to start conditions over.
I would have your Arduino record everything and only send send a ready to move signal (Or alternatively keep pulsing not ready to move yet). Have the V5 look for that one condition and use it to move.
How will I send one bit every 10ms for temp, humidity ,and air quality?
All I need are readings every .5-1 sec.
Or, if I tell the robot bad air or bad humidity, will that be 1 bit, so I will output a 1, 2, 3, 4 to the v5 and use if statement to tell the robot what to do?
Do I wire 5v, ground and a data pin to the v5s 3-wire ports for the data?
Ya you just wire 5v ground and a data pin between V5 and gpio on arduino. And every 10ms, set the pin to the data you want to read.
@vexvoltage has an excellent point though. We can just make the “logic” that decides what humidity is okay on the arduino and instead of sending over all the data just send over a single bit “good” or “bad”.
Ok, I will try that and let you guys know how it goes soon.
I just want to make sure you know that V5 vision sensor does not let you process raw image data on V5 brain at the moment. It works by taking signatures of the desired (color) codes for the objects you are looking for and then returns an array of coordinates for several easily recognized (large) objects matching those codes: