RPUpi - a shield for Pi Zero and RS-422 over CAT5

Shield for RS-422 over CAT5 with a Pi Zero host

Similar projects worth following
This Shield connects a Pi Zero host to RS-422. It has two RJ45 for daisy-chain and a bus manager for transceiver control.

A Pi Zero can install the AVR toolchain with "sudo apt-get install gcc-avr binutils-avr gdb-avr avr-libc avrdude". I also put Samba on the Pi so that I can edit my project files from a Windows computer that has some good displays. To compile the Makefile is run over an SSH connection.

  • ^3 SPI Interface

    ronald.sutherland08/24/2017 at 06:16 0 comments

    Firmware SpiSlv is used to enable the SPI port on a RPUno (ATmega328p).

    After loading the firmware on an RPUno and enabling the AVR's SPI I next need the Raspberry Pi SPI hardware setup. Raspian needs its interface master driver enabled (e.g. raspi-config).

    Raspibin has an spi group setup in /etc/udev/rules.d/99-com.rules. So I can add my user name to that group for the system to allow me to use the interface.

    sudo usermod -a -G spi rsutherland
    # logout for the change to take

    Next I compile and run spidev_test.c on the Pi with:

    gcc -o spidev_test spidev_test.c
    # run with
    ./spidev_test -s 100000 -D /dev/spidev0.0
    ./spidev_test -s 500000 -D /dev/spidev0.0
    ./spidev_test -s 1000000 -D /dev/spidev0.0
    ./spidev_test -s 2000000 -D /dev/spidev0.0
    spi mode: 0
    bits per word: 8
    max speed: 500000 Hz (500 KHz)
    FF 40 00 00 00 00
    95 FF FF FF FF FF
    AD F0

    Note: The output is offset a byte since it was sent back from the AVR. I see errors at 1MHz and 2MHz. The RPUpi^3 has a 74LVC07 buffer that pulls down through a 10kOhm resistor on SCK and MOSI. The circuit between that resistor and the AVR has some capacitance which will limit the speed (if there is a need for higher speed it may be possible to swap in a 1k resistor).

    SPI Evaluation

  • ^3 Bootload Remote AVR

    ronald.sutherland08/24/2017 at 06:12 0 comments

    Bootload Remote AVR

    The hostname of the Pi Zero is pi3, it was the third Pi Zero I have setup (it is a bad hostname). The default bootload address on the RPUftdi (e.g. my multi-drop RS-422 board) is '0', and I have not changed it, I keep the i2c-debug firmware on an ATmega328p board under the RPUftdi for use on my test bench, so I will just upload that same program compiled from the Pi Zero.

    rsutherland@pi3:~/Samba/RPUno/i2c-debug $ uname -a
    Linux pi3 4.9.41+ #1023 Tue Aug 8 15:47:12 BST 2017 armv6l GNU/Linux
    rsutherland@pi3:~/Samba/RPUno/i2c-debug $ make bootload
    avr-gcc -Os -g -std=gnu99 -Wall -ffunction-sections -fdata-sections  -DF_CPU=16000000UL   -DBAUD=38400UL -I.  -mmcu=atmega328p -c -o main.o main.c
    avr-gcc -Os -g -std=gnu99 -Wall -ffunction-sections -fdata-sections  -DF_CPU=16000000UL   -DBAUD=38400UL -I.  -mmcu=atmega328p -c -o i2c-scan.o i2c-scan.c
    avr-gcc -Os -g -std=gnu99 -Wall -ffunction-sections -fdata-sections  -DF_CPU=16000000UL   -DBAUD=38400UL -I.  -mmcu=atmega328p -c -o i2c-cmd.o i2c-cmd.c
    avr-gcc -Os -g -std=gnu99 -Wall -ffunction-sections -fdata-sections  -DF_CPU=16000000UL   -DBAUD=38400UL -I.  -mmcu=atmega328p -c -o ../Uart/id.o ../Uart/id.c
    avr-gcc -Os -g -std=gnu99 -Wall -ffunction-sections -fdata-sections  -DF_CPU=16000000UL   -DBAUD=38400UL -I.  -mmcu=atmega328p -c -o ../lib/timers.o ../lib/timers.c
    avr-gcc -Os -g -std=gnu99 -Wall -ffunction-sections -fdata-sections  -DF_CPU=16000000UL   -DBAUD=38400UL -I.  -mmcu=atmega328p -c -o ../lib/uart.o ../lib/uart.c
    avr-gcc -Os -g -std=gnu99 -Wall -ffunction-sections -fdata-sections  -DF_CPU=16000000UL   -DBAUD=38400UL -I.  -mmcu=atmega328p -c -o ../lib/twi.o ../lib/twi.c
    avr-gcc -Os -g -std=gnu99 -Wall -ffunction-sections -fdata-sections  -DF_CPU=16000000UL   -DBAUD=38400UL -I.  -mmcu=atmega328p -c -o ../lib/rpu_mgr.o ../lib/rpu_mgr.c
    avr-gcc -Os -g -std=gnu99 -Wall -ffunction-sections -fdata-sections  -DF_CPU=16000000UL   -DBAUD=38400UL -I.  -mmcu=atmega328p -c -o ../lib/adc.o ../lib/adc.c
    avr-gcc -Os -g -std=gnu99 -Wall -ffunction-sections -fdata-sections  -DF_CPU=16000000UL   -DBAUD=38400UL -I.  -mmcu=atmega328p -c -o ../lib/parse.o ../lib/parse.c
    avr-gcc -Wl,-Map,  -Wl,--gc-sections  -mmcu=atmega328p main.o i2c-scan.o i2c-cmd.o ../Uart/id.o ../lib/timers.o ../lib/uart.o ../lib/twi.o ../lib/rpu_mgr.o ../lib/adc.o ../lib/parse.o -o I2c-debug.elf
    avr-size -C --mcu=atmega328p I2c-debug.elf
    AVR Memory Usage
    Device: atmega328p
    Program:    8684 bytes (26.5% Full)
    (.text + .data + .bootloader)
    Data:        375 bytes (18.3% Full)
    (.data + .bss + .noinit)
    rm -f I2c-debug.o main.o i2c-scan.o i2c-cmd.o ../Uart/id.o ../lib/timers.o ../lib/uart.o ../lib/twi.o ../lib/rpu_mgr.o ../lib/adc.o ../lib/parse.o
    avr-objcopy -j .text -j .data -O ihex I2c-debug.elf I2c-debug.hex
    rm -f I2c-debug.elf
    avrdude -v -p atmega328p -c arduino -P /dev/ttyAMA0 -b 115200 -U flash:w:I2c-debug.hex
    avrdude: Version 6.1, compiled on Jul  7 2015 at 10:29:47         Copyright (c) 2000-2005 Brian Dean,         Copyright (c) 2007-2014 Joerg Wunsch
             System wide configuration file is "/etc/avrdude.conf"         User configuration file is "/home/rsutherland/.avrduderc"         User configuration file does not exist or is not a regular file, skipping
             Using Port                    : /dev/ttyAMA0         Using Programmer              : arduino         Overriding Baud Rate          : 115200         AVR Part                      : ATmega328P         Chip Erase delay              : 9000 us         PAGEL                         : PD7         BS2                           : PC2         RESET disposition             : dedicated         RETRY pulse                   : SCK         serial program mode           : yes         parallel program mode         : yes         Timeout                       : 200         StabDelay                     : 100         CmdexeDelay                   : 25         SyncLoops                     : 32         ByteDelay                     : 0         PollIndex                     : 3         PollValue                     : 0x53         Memory Detail                 :
     Block Poll Page Polled Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- --------- eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00 lock 0 0 0 0 no 1 0...
    Read more »

  • ^2 Board Arrived

    ronald.sutherland06/04/2017 at 04:02 0 comments

    OSHPark did a great job as always, unfortunately, I had a brain fart and forgot that the AVR microcontroller under the shield connects to the RS-422 transceiver through the 74LVC07 buffers I used. I was trying to use the buffers IOFF state to allow the Pi Zero to be powered off without pulling down the RS-422 bus.

    When U3 (74LVC07) does not have power the serial RX and TX from shield can not reach the RS-422 transceivers.

    For testing, I need to cut U3 power from the PI3V3 node and bridge it to the +3V3 node.

    Power RS-422 Buffer

    So far this hack is working, but I have another board on the way so this will soon be back on a spin loop thread.

View all 3 project logs

Enjoy this project?



ronald.sutherland wrote 06/08/2017 at 20:58 point

It helps to be able to iterate the board. Mistakes can be made and the cost is not that painful. I don't even do projects on prototype boards nowadays (but still doing test setups with them).

  Are you sure? yes | no

oshpark wrote 06/08/2017 at 20:34 point

Great idea!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates