I am trying to get a photon to talk to the Omron HVC B5T-007 which is a human vision system that incorporates 10 algorithms of the OKAO™ Vision Image Sensing Technology to recognize people. The device can be used to count faces or bodies in a room and output that detection result. It can do the heavy processing that the photon cannot.
I can talk to the device via a USB connection and using an app on a PC I know the device is working. I want to interface the HVC to a photon to be able to sent the detection results to the cloud. The UART connection uses NRZ method, 3.3V TTL, 9600 baud default, 1 start bit, 8 data bits 1 stop bit and no parity. It is being powered from the photon VIN (it runs on 5V) and connect the GND to photon GND. The photon is powered vis USB and the photon uses Serial to output debug. I have swapped the TX and RX lines. One line is used as RESET (active low) - this is working.
The host sends a command to the HVC which receives it and processes it then sends the results to the host. The simplest command 00h with the HVC is to request the model and version. The best response I have received so far from sending FEh 00h 00h 00h (synchronous code, command number, LSB data length, MSB data length) to Serial1 is to receive 63 00h. Sometimes I get Serial1 not available. Has anyone had any experience interfacing to this device and can provide avenues to explore to get it to work? Thanks
Where do you get that message from?
What code are you using?
This is a snippet from the receive result function:
if (Serial1.available()) //there is data in the Serial1 buffer
inByte = Serial1.read();
Serial.printlnf("First byte read: %02X", inByte);
if (inByte == SYNC_CODE) //if data starts with SYNC_CODE then
errorCode = Serial1.read(); //read result or errorCode
Serial.printlnf("Sync Code Read - result code is: %02X", errorCode);
data_length = read32(); //read data length in bytes
Serial.printlnf("Data Length is: %i", data_length);
Serial.println("Serial1 not available");
This answers your question? I never get a SYNC_CODE in the result as the first byte.
The datasheet for the Omron board specs a 450mA operating current. The Photon takes between 80 and 430mA, so technically you’re probably exceeding the spec’d maximum of 500mA for USB 2.0. I have no idea if this is the source of your issue but it’s something to consider.
In addition to @blave’s sound advice you may need to flush the buffer of all non-SYNC_CODE bytes till you actually get one in a tight loop (keeping the cloud connection serviced tho’).
while (Serial1.available() && (inByte = Serial1.read()) != SYNC_CODE) Particle.process();
// ensure you have enought data in buffer to do the rest or delay execution
@blave Thanks for that tip. I have tried powering the Omron board separately - interestingly I now get no bytes sent in response rather than the 63 00h values I was getting! Not sure if this is good or bad.
Stupid question but we had these issues before
- You do have common ground for board and Photon?
I have tried this and it just skips the 63 00h bytes - i.e. I am still not getting any SYNC CODE.
Another thought is that the interface is a little fiddly at startup. I have this as my first statement in
digitalWrite(TX, LOW); //ensure RX pin on HVC is not floating when powered on
Yes - not a silly question and a lot of time has been spent on other devices!
I have got hold of Omron Components support - my support request will need to be taken back to Japan. Wait and see what they say. Disappointing as this unit is impressive when driven from a PC via USB using Omron’s evaluation software.
You don’t happen to have a Logic Analyzer?
Nope, but I do have a DSO. Probably difficult to set up I am actually wondering if there is an issue with the TX and RX pins on the photon. I will try another one and try and cross that off the list.
@ScruffR, Update if you interested to close this thread. I tried a small change in the sending code having looked at the sample UART solution in C that I received from Omron. The instructions for the command stated that after sending the initial SYNC-CODE byte you should wait at least 100 millisec before send the rest of the command. The example solution contained no such delay. Removed the delay and it worked!