This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AFE4404: Reading data directly from optical sensor without using TI software

Part Number: AFE4404

I have an AFE4404 optical sensor and I am trying to read the data directly into memory without the intermediary of the TI software package. Using a Python Package called PySerial, I was able to see that the port was being read but when I went to read from the serial port, I got no data back. 

Do you have any recommendations on a library (does not need to be Python specific) that may be able to read through this data? 

  • Hi Sharabesh,

    I am assuming you have the EVM for AFE4404 and you want to use it without TI's software. If this is the case, PySerial can be used to control the EVM as well as read data from the EVM.
    Also there is a protocol to followed while communicating with the AFE4404EVM. Please refer the following post for the protocol.
    e2e.ti.com/.../494542

    Regards,
    Prabin
  • Hi Prabin, 

    Thank you for the reply, I was indeed talking about the EVM for the module.  

    Based on the protocol, it appears that I should be writing the bit string provided; 
    EG 

    “0x01 0x2A 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x0D” 

    to specify the kind of data I want to recieve (where the above would be for continuous data). 

    Using Pyserial, I do the following: 

    ser = serial.Serial ('<port name>') # Connect to the device 
    
    ser.write(“0x01 0x2A 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x30 0x0D”) 
    
    ser.read() 

    But I still cannot seem to recieve any data back from the device. 

    Is my approach over-simplifying the process? 

  • Hi Sharabesh,

    Can you please try as given below. The way you are passing commands is not correct and you have to specify the number of bytes to read for "ser.read()" command.

    import serial
    ser = serial.Serial('COM13',baudrate = 9600,timeout = 50) # open serial port
    print(ser.name) # check which port was really used
    ser.write("\x01\x2A\x30\x30\x30\x30\x30\x30\x30\x30\x0D")
    my_string = ser.read(22)
    print " ".join(hex(ord(n)) for n in my_string)
    ser.close()

    Regards,
    PRabin
  • Hi Prabin, 

    Thank you again for the reply. That seems to have done the trick! 

    I was just a little bit confused the values of the data that I was getting back.

    When running the GUI, I consistently get voltages back in terms of decimal numbers (eg: 0.455, 0.006, 0.7975), but when executing a typical run of the script, there is not a single column in the table with comparable values: 

    my_string = ser.read(22) 
    
    [x for x in my_string] #ord is no longer needed as per Python 3.x 
    
    # [1, 2, 160, 89, 0, 184, 69, 0, 36, 137, 2, 48, 166, 0, 0, 0, 0, 244, 226, 1, 0, 13]

    Would there be a reason that the values I am trying to get (even in the LED2 and LED1 columns) are so divergent from what is being observed in the GUI for the LED1 and LED2 columns, or is this a problem in how I am handling the data. 

    Thanks again.

  • Hi Sharabesh,

    From the raw data, you have to extract the AFE4404's output using the communication protocol. I.e. you have to extract 18 bytes (6 channels, each channel has 3 bytes) from the 22 bytes of data.
    After extraction you have to combine 3 bytes of data for each channel into 24 bits of data ( out of which lower 22 bit is used).
    Resulting 22 bit ADC code have to converted into voltage as 22_bit_data*1.2/(2^21).

    All of above data manipulation is done internally in GUI to get output in voltage, whereas for you case you have to handle yourself.

    Regards,
    Prabin