• Resolved

PGA460-Q1: Interfaced to Arduino Uno_source code

Prodigy 80 points

Replies: 10

Views: 167

Part Number: PGA460-Q1

Hi,

    Could you please share me the arduino source code for interfacing the PGA460-Q1.I have designed and developed the ultrasonic sensor module using PGA460-Q1 driver IC and Murata sensor.I would like to inteface this sensor with arduino uno for getting the distance information.Please provide the suitable source code for this 

Thanks & regards

Sreejith S V

  • Hi Sreejith,

    For PGA460 software development, I recommend that you start with the PGA460 Software Development Guide and PGA460 Energia Library and Code Example downloads. These will help guide you with USART (UART and SPI) specific examples for the Energia and Arduino microcontroller kits.

    For information on the general structure of the USART packet, refer to section "7.3.6.2.1 USART Asynchronous Mode" of  the datasheet: http://www.ti.com/lit/ds/symlink/pga460-q1.pdf. Note the non-default 2-stop bit requirement for the UART configuration.

    Akeem Whitehead // Texas Instruments // ASC-SENSING-CSPS // Applications Engineer
    Visit our Ultrasonic Sensing FAQ page for additional information.
  • In reply to Akeem Whitehead:

    Thanks Akeem for your quick response.Will go through these documents and get back to you if any support is required for the same.

    Thanks & Regards

    Sreejith

  • In reply to Sreejith S V:

    I just gone through the document and tried to compile the code using arduino id,getting so many errors.I solved  most of the errors,but still there is some errors related to the library functions.Could you please share me the modified code which is suitable for arduino ide and arduino controller.My actual aim is to get the distance data from the sensor via one wire communication using arduino .Sensor board is ready with pga460 and murata sensor.

  • In reply to Akeem Whitehead:

    I just gone through the document and tried to compile the code using arduino id,getting so many errors.I solved  most of the errors,but still there is some errors related to the library functions.Could you please share me the modified code which is suitable for arduino ide and arduino controller.My actual aim is to get the distance data from the sensor via one wire communication using arduino .Sensor board is ready with pga460 and murata sensor.

  • In reply to Sreejith S V:

    Hi Sreejith,

    Does Arduino Uno support Serial1? The code uses two serial ports: one for serial communication to the PC, and the other for serial/UART communication to the PGA460.

    To get the PGA460 Energia library to run in Arduino Mega:

    1) Delete the following from the PGA460EnergiaLibrary_vx.x.x library folder: "PGA460_SPI.cpp", "PGA460_SPI.h", "utility" folder. The SPI functions for the PGA460 were customized specifically for the MSP430F5529 microcontroller. SPI support is only enabled through Energia, not Arduino at this time.

    2) Replace all instances of #include <Energia.h> to #include <Arduino.h> in the library files (PGA40_USSC.h/.cpp)

    3) In all files, change any reference of "PUSH2", "GREEN_LED", "RED_LED" to a Arduino pin numbers. These designators are specific to the Energia.h file for the LaunchPads.

    4) Delete case 3 from the initBoostXLPGA460 function in PGA460_USSC.cpp.

    Akeem Whitehead // Texas Instruments // ASC-SENSING-CSPS // Applications Engineer
    Visit our Ultrasonic Sensing FAQ page for additional information.
  • In reply to Akeem Whitehead:

    Hi Akeem,

                      Thanks for your reply.I already solved the issues by studying the code and modified for  Arduino IDE.Successfully compiled for Arduino Mega .My sensor PCB fabrication is in progress and after getting it assembled will test this code using arduino mega and sensor board.Will let you post the status.

    Can I interface multiple sensor using the same code and what will be the interface for multiple sensor interface?

    My assumption is by changing the address we can interface multiple sensors using one wire interface.For that I need to connect serial to onewire transceiver chip in between arduino serial and sensor board and connect all the sensor boards IO line to transceiver output?Is this correct,Please let me know

    Thanks

    Sreejith

  • In reply to Sreejith S V:

    Hi Sreejith,

    The PGA460 offers four different interfaces: UART, SPI, OWU, and TCI

    OWU and TCI are automotive interfaces referenced to high-level battery. In this case you would need a transceiver to level shift from VPWR (i.e. 12V) to 5V for a logic high.If your application is not automotive, I recommend that you use UART or SPI so you can directly interface the PGA460 to the Arduino without the need for a transceiver. UART/SPI is much easier to work with anyway.

    Because the PGA460 has a three-bit software address (UART_ADDR), you can have up to eight PGA460s on the same UART or SPI bus. Refer to PGA460 FAQ #4.4.11 (http://www.ti.com/lit/pdf/slaa733) for details on auto-addressing:

    4.4.11 Is daisy-chain supported by the PGA460? Can the master controller automatically differentiate and program the PGA460 UART address? Daisy-chain auto-addressing and automatic slave node position detection (SNPD) are not supported by the PGA460. External hardware or switches must be used in combination with the external master controller to automatically assign address to multiple PGA460 devices connected to the same bus. The example provided is interchangeable for the IO and TX pin. When switching IO, be sure select a bidirectional switch rated for VPWR (up to 30 V). The TX pin is a unidirectional pin rated at either 3.3V (default) or 5.0 V.

    Akeem Whitehead // Texas Instruments // ASC-SENSING-CSPS // Applications Engineer
    Visit our Ultrasonic Sensing FAQ page for additional information.
  • In reply to Akeem Whitehead:

    Hi Akeem,

                   My PGA460 with sensor board is now ready and started testing using arduino mega.I connected the TXD and RXD pins to RX0 and TX0 of arduino mega and supplied 12VDC power input.But the sensor is not responding.I have attached my schematic and arduino serial monitor screen shots.Please check and advice for troubleshooting the same

    Regards

    Sreejith

  • In reply to Sreejith S V:

    Hi Akeem,

                        I have solved the issues and getting the object distance data from the sensor.The following are the issues

    1)I am using 5V micro so need to connect 100k pull up to 5V

    2) UART Communication port required in Arduino is TX1 and RX1 

    3) Required to enable the temperature compensation register bit else remove the mosfet and connect ground  to transformer secondary pin 4

    Could you please suggest me  the actual configuration required for my hardware and the meaning of the red marked configurations .I am using  Murata MA58MF14-7N sensor

    1. Communication Mode: 0=UART, 1=TCI, 2=OneWireUART ... 0
    2. UART kBaud: 0=9.6, 1=19.2, 2=38.4, 3=57.6, 4=74.8, 5=115.2 ...0
    3. P1 and P2 Thresholds: 0=%25, 1=50%, or 2=75% of max ... ?
    4. Transducer Settings: 0=Murata MA58MF14-7N, 1=Murata MA40H1SR, x=Skip ... 0
    5. TVG Range: 0=32-64dB, 1=46-78dB, 2=52-84dB, or 3=58-90dB, x=Skip ...?
    6. Fixed TVG Level: 0=%25, 1=50%, or 2=75% of max, x=Skip ... ?
    7. Minimum Distance = 0.1m * BYTE ... ?
    8. Run System Diagnostics?: 0=No, 1=Yes ... 0
    9. Echo Data Dump: 0=None, 1=P1BL, 2=P2BL, 3=P1LO, 4=P2LO,... ?
    10. Burn User EEPROM?: 0=No, 1=Yes ... ?
    11. Command Cycle Delay: 10ms * BYTE ... ?
    12. Number of Objects to Detect (1-8) = BYTE ... 1
    13. UART Address of PGA460 (0-7) = BYTE ... 0

    Regards

    Sreejith

  • In reply to Sreejith S V:

    Sreejith,

    Your items marked in red can be described as follows (from the PGA460_USSC.cpp file of the PGA460 Energia Library and Code Example download).

    If you do not have pre-determined PGA460 EEPROM register values from EVM-GUI evaluation, use the mid-code values for the threshold and TVG settings as a starting point.

    Item #3:

    /*------------------------------------------------- initThresholds -----

    | Function initThresholds
    |
    | Purpose: Updates threshold mapping for both presets, and performs bulk threshold write
    |
    | Parameters:
    | thr (IN) -- updates all threshold levels to a fixed level based on specific percentage of the maximum level.
    | All times are mid-code (1.4ms intervals).
    | Modify existing case statements, or append additional case-statement for custom user threshold configurations.
    | • 0 = 25% Levels 64 of 255
    | • 1 = 50% Levels 128 of 255
    | • 2 = 75% Levels 192 of 255
    |
    | Returns: none
    *-------------------------------------------------------------------*/

    Item # 5&6:

    /*------------------------------------------------- initTVG -----
    | Function initTVG
    |
    | Purpose: Updates time varying gain (TVG) range and mapping, and performs bulk TVG write
    |
    | Parameters:
    | agr (IN) -- updates the analog gain range for the TVG.
    | • 0 = 32-64dB
    | • 1 = 46-78dB
    | • 2 = 52-84dB
    | • 3 = 58-90dB
    | tvg (IN) -- updates all TVG levels to a fixed level based on specific percentage of the maximum level.
    | All times are mid-code (2.4ms intervals).
    | Modify existing case statements, or append additional case-statement for custom user TVG configurations
    | • 0 = 25% Levels of range
    | • 1 = 50% Levels of range
    | • 2 = 75% Levels of range
    |
    | Returns: none
    *-------------------------------------------------------------------*/

    Item #7:

    The Energia program will ignore any objects read as less than the minimum distance value in increments of 10cm. Set to a value of '0' to disable this master controller very short distance mask. This was put in place in the event the burst-and/or-decay signature triggered the threshold capture.

    Item#9:

    /*------------------------------------------------- runEchoDataDump -----
    | Function runEchoDataDump
    |
    | Purpose: Runs a preset 1 or 2 burst and or listen command to capture 128 bytes of echo data dump.
    | Toggle echo data dump enable bit to enable/disable echo data dump mode.
    |
    | Parameters:
    | preset (IN) -- determines which preset command is run:
    | • 0 = Preset 1 Burst + Listen command
    | • 1 = Preset 2 Burst + Listen command
    | • 2 = Preset 1 Listen Only command
    | • 3 = Preset 2 Listen Only command
    | • 17 = Preset 1 Burst + Listen broadcast command
    | • 18 = Preset 2 Burst + Listen broadcast command
    | • 19 = Preset 1 Listen Only broadcast command
    | • 20 = Preset 2 Listen Only broadcast command
    |
    | Returns: none
    *-------------------------------------------------------------------*/

    Item #10:

    /*------------------------------------------------- burnEEPROM -----
    | Function burnEEPROM
    |
    | Purpose: Burns the EEPROM to preserve the working/shadow register values to EEPROM after power
    | cycling the PGA460 device. Returns EE_PGRM_OK bit to determine if EEPROM burn was successful.
    |
    | Parameters:
    | none
    |
    | Returns: bool representation of EEPROM program success
    *-------------------------------------------------------------------*/

    Item #11:

    The amount of time between each burst/listen command as the Energia program loops on the master controller. Can be set in delay intervals of 10ms multipliers.

    Akeem Whitehead // Texas Instruments // ASC-SENSING-CSPS // Applications Engineer
    Visit our Ultrasonic Sensing FAQ page for additional information.