Difference between revisions of "Arduino Based Test Station"

From Land Boards Wiki
Jump to navigation Jump to search
 
Line 151: Line 151:
  
 
Here's some useful pieces of Arduino code
 
Here's some useful pieces of Arduino code
 +
 +
=== Wait for Host Serial to Connect ===
 +
 +
<pre>
 +
  Serial.begin(9600);
 +
  while (!Serial);    // wait for serial port to connect. Needed for native USB
 +
</pre>
  
 
=== uint8_t checkI2CAddr(uint8_t addr) ===
 
=== uint8_t checkI2CAddr(uint8_t addr) ===

Latest revision as of 13:58, 23 March 2022

DIGIO32-I2C P1994 720px.jpg

Hardware

BLACK-PILL-HUB

Black-Pill-Hub P1383-720px.jpg

LED-32

LED-32-P426-720px.jpg

DIGIO32-I2C

DIGIO32-I2C-P232-720px.jpg

Personality EEPROM

  • Tests cards without personality EEPROM
  • Tests cards with personality EEPROM
    • Personality EEPROM follows Raspberry Pi Hat EEPROM format
    • Test station writes EEPROM
    • Test station uses EEPROM contents (if present) to determine which test to run

Example Personality EEPROM - DIGIO-128

Reading EEPROM
Family=ODAS
Company=land-boards.com
Product=DIGIO-128

Black Pill Setup

Resources

  • Plenty of resources
    • EEPROM - 524288 bytes
    • SRAM - 131072 bytes
Sketch uses 50316 bytes (9%) of program storage space. Maximum is 524288 bytes.
Global variables use 3828 bytes (2%) of dynamic memory, leaving 127244 bytes for local variables. Maximum is 131072 bytes.

Programming

Programming Setup

DFU Programming

STM32F4-Black-Pill-Board-oriented.jpg

    • Start the STM32CubeProg
    • From the Tools > Board > STM32 Board, select Generic STM32F4 series
    • Select Tools > Board Part Number > BlackPill F411CE
    • Under USB Support, select CDC (generic "Serial" supersede U(S)ART)
    • Under Upload method, select SMT32CubeProgrammer(DFU)
    • Use the onboard BOOT0 and NRST button to put the board into bootloader mode:
      • press and hold the BOOT0 button
      • press and release NRST (reset) button to power cycle the processor
      • release BOOT0 button
      • Sometimes removing the USB cable and plugging it back in while pressing BOOT0 button works better
    • Upload sketch

BlackPill Config.png

  • Displays in IDE
USB speed   : Full Speed (12MBit/s)
Manuf. ID   : STMicroelectronics
Product ID  : STM32  BOOTLOADER
SN          : 348C35983539
FW version  : 0x011a
Device ID   : 0x0431
Device name : STM32F411xC/E
Flash size  : 512 KBytes (default)
Device type : MCU
Device CPU  : Cortex-M4



Memory Programming ...
Opening and parsing file: ODASTESTER.ino.bin
  File          : ODASTESTER.ino.bin
  Size          : 49132 Bytes
  Address       : 0x08000000 


Erasing memory corresponding to segment 0:
Erasing internal memory sectors [0 2]
erasing sector 0000 @: 0x08000000 done
erasing sector 0001 @: 0x08004000 done
erasing sector 0002 @: 0x08008000 done
Download in Progress:


File download complete
Time elapsed during download operation: 00:00:02.263

RUNNING Program ... 
  Address:      : 0x8000000
Start operation achieved successfully

Other Programming

SerialPropogramming (AN3155).PNG

Useful Arduino Code

Here's some useful pieces of Arduino code

Wait for Host Serial to Connect

  Serial.begin(9600);
  while (!Serial);    // wait for serial port to connect. Needed for native USB

uint8_t checkI2CAddr(uint8_t addr)

Check if there is an I2C device at an address

////////////////////////////////////////////////////////////////////////////
// uint8_t checkI2CAddr(uint8_t addr) - Check that an I2C device is present
// Pass: addr - I2C address
// Returns:
//      0 : success
//      1 : data too long to fit in transmit buffer
//      2 : received NACK on transmit of address
//      3 : received NACK on transmit of data
//      4 : other error
////////////////////////////////////////////////////////////////////////////

uint8_t checkI2CAddr(uint8_t addr)
{
  Wire.beginTransmission(addr);
  return (Wire.endTransmission());
}

uint8_t checkIfMCP23017(uint8_t addr)

Check if an I2C device is an MCP23017 at an address

////////////////////////////////////////////////////////////////////////////
//  uint8_t checkIfMCP23017(uint8_t addr)
//  Check to see if the I2C part is a MCP23017
//    The GPU Pullup A register (internal register address 0x0c) is present
//    in a MCP23017 but not in a MCP23008.
//  Pass: addr - I2C address
//  Returns
//    0 : Not an MCP23017
//    1 : Likely an MCP23017
////////////////////////////////////////////////////////////////////////////

uint8_t checkIfMCP23017(uint8_t addr)
{
  // Write 0x55 to MCP23017_GPPUA (0x0c)
  Wire.beginTransmission(addr);
  Wire.write(0x0c);
  Wire.write(0x55);
  Wire.endTransmission(1);
  // Read back
  Wire.beginTransmission(addr);
  Wire.write(0x0c);
  Wire.endTransmission();
  Wire.requestFrom(addr,  1);
  if (Wire.read() == 0x55)
  {
    Serial.println(F("Detected MCP23017"));
    return 1;
  }
  else
  {
    Serial.println(F("Detected MCP23008"));
    return 0;
  }
}

Cards Supported

Goal is to have automated tests for as many cards as possible. The currently tested cars are.

Menu Options

Select the board type
1 - DIGIO16-I2C board
2 - DIGIO-128 board
3 - OptoIn8-I2C board
4 - OptoOut8-I2C board
5 - DIGIO32-I2C board
6 - PROTO16-I2C board
7 - ODAS-PSOC5 board
8 - ODAS-RELAY16 board
A - DIGIO-128/64 board
9 - TBD board
X - Boards without EEPROMs
Select board > X
Select the board type
1 - I2CIO8 board
2 - I2CIO8X board
3 - SWLEDX8-I2C board
4 - OPTOFast/Small Non-Inverting board
5 - OPTOFast/Small Inverting board
6 - I2C-RPT-01 board
7 - I2C-RPT-08 board
8 - OptoFastBi board

Cable Sets

ODTSTSTR CBLS P119 720pv.jpg

  • Particular cable sets for cards
  • Bounce LED and Loopback to Test Station Cables

Software