4

Initial Setup of Microcomputer (RPi 4)

 3 years ago
source link: https://opensourceleg.com/initial-setup-of-microcomputer-new/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Initial Setup of Microcomputer (RPi 4)

The schematic below outlines how the OSL is controlled. LiPo batteries are used to power the motors while a microcomputer communicates executables to the actuators, and separate joint and motor encoders enable low-level closed feedback loops to increase the accuracy of joint angles. The following is a step-by-step guide on how to utilize these features and get the OSL running properly.

Table of Contents

ControlSchematic.jpg

Ordering a Raspberry Pi and SD Card

Download Image onto SD Card

Adding a WiFi Network to the Raspberry Pi

Adding Email Addresses to Startup Mailer

Windows Device: Connecting to Raspberry Pi After First Connection

Mac Device: Connecting to Raspberry Pi After First Connection

Order Raspberry Pi and SD Card

  1. Click here to be directed to a page where you can order a Raspberry Pi. The Raspberry Pi 4 Model B  is preferred.
  2. Purchase a Micro SD card with at least 16 GBs of storage from a retailer.

Download and Flash Image onto SD Card

Click here to download the SD image, and includes necessary startup / accessibility / libraries that facilitate use in controlling the OSL (and other robots in general).  The image is 10.3 and is the latest version of Rasbian (Debian Buster).  It is pre-loaded / includes the following functionality:

  • Wifi + access point backup on boot for immediate wireless access
  • Emails its IP address upon boot, if connected to WiFi
  • Legacy Adafruit / other Python libraries for popular ICs (MPU-6050, LS7366R, ADS-1X15, etc.)
  • Example python code from other projects (e.g. MIT CSEA Knee state machine)
  • Dephy Actuator Package libraries for OSL project

Note that we deliberately set the Raspberry Pi to try connecting Wifi and email you its IP address if connected successfully; if not, it’ll open as a wireless access point, which runs a standalone network that you can connect from your computer. This booting sequence makes it easy to set up and use the Raspberry Pi even not in your usual workplace, instead of using it with other peripherals. However, you should always try to set up a Wifi connection (even hotspot from your smartphone works), since using the access point will make your computer out of connection with the Internet!

To use the image, you’ll need to flash it on a micro SD card, which can be performed using imageUSB or follow the tutorial from Raspberry Pi with our image file.  After it is flashed, it can be inserted into the SD card slot on the Raspberry Pi.

Installing PuTTY on Windows Computer

If you are using a Mac OS or Linux computer, you can access the Raspberry Pi with Terminal, which is built-in for both operating systems.

  1. Download the PuTTY application by clicking here and being transferred to the PuTTY website. Once at the website, download either the 32-bit or 64-bit (32-bit is recommended) application. The links to download PuTTY will be titled “putty-0.70-installer.msi” and “putty-64bit-0.70-installer.msi”.
  2. Open the downloaded file and install the PuTTY file on your computer.

Adding a WiFi Network to the Raspberry Pi

  1. Connect the USB port on Pi to a power source (your computer or a USB charger) with the SD card inserted into the Pi. A red and green light should light up on the Raspberry Pi. The first time booting takes about 3 minutes, and the green light will stop flashing.
  2. Open up the panel on your computer that displays all available WiFi networks.
  3. Click on the network that says “Neurbionics_RPi“, type “aaaaa11111” for the password, and connect to it.
  4. If using Windows, open PuTTY:
    1. A PuTTY Configuration window will open up. Under the Host Name section, type “10.0.0.200”  and use SSH for the connection type. After entering these in, click “Open”. A new command window will open.
    2. Login as “pi“, press Enter, and then type the password “neurobionics” and press Enter.
    3. You are now connected to the Pi.
  5. If using Mac OS or Linux, open Terminal:
    1. Type “ssh [email protected]” and press Enter.
    2. Type the password “neurobionics” and press Enter.
    3. You are now connected to the Pi.
  6. In the command line, type “sudo nano /etc/wpa_supplicant/wpa_supplicant.conf” then press Enter. “sudo” is a keyword to execute commands as a superuser for higher security privileges in Linux (use carefully), and “nano” is a built-in editor for Debian.
  7. A file named “wpa_supplicant.conf” will open up with a list of network settings.
  8. Edit the file as the following figure and change it to your wifi configuration. More detail can be referred to Raspberry Pi’s tutorial.
    RPi_wpa_configuration-1.png
  9. When network settings have been input, press “Control+x“.
  10. Press “y” and then “Enter” to save settings.
  11. Type “nano ~/startup/startup_mailer.sh” into the Terminal command line and press Enter.
  12. In the 31st line of the script, where it says “declare -a ssids = ()“, type your network name into the parenthesis inside of quotation marks.
    RPi_startup_mailer.png
  13. Press “Control+x“.
  14. Press “y” and then “Enter” to save settings.

Adding Email Addresses to Startup Mailer

Adding your email address to the startup mailer will make connecting to the Raspberry Pi much easier in the future. Since you added your network earlier, the Pi will automatically connect to it, and then by adding your email to the startup mailer, you will receive an email containing the IP Address of the Pi so that you can access the internet while working directly on the Pi.

  1. In the Terminal command line, type “nano ~/startup/startup_mailer.py” and press Enter.
  2. On the 10th line of code, where “recipients” are listed, add your email inside brackets and quotation marks after the “=” sign. If you want to send emails to multiple accounts, add a comma inside the brackets to the end of the last email, then type your email inside quotation marks. An example is shown below with multiple email addresses.
    RPi_startup_mailer_email.png
  3. Press “Control+x“.
  4. Press “y” and then “Enter” to save settings.
  5. These setting needs rebooting the Raspberry Pi to activate. Type “sudo reboot” and press Enter.
  6. You will be disconnected and the Raspberry Pi will reboot.

Connecting to Raspberry Pi on Windows Computer After First Connection

If you follow the above instruction correctly, your Raspberry Pi should connect to your Wifi and email you its IP address. If not, it will boot as an access point and you can connect to it with the above instruction. Make sure you set up your wifi correctly.

  1. Connect Raspberry Pi to a power source.
  2. Open up the PuTTY desktop app.
  3. A PuTTY Configuration window will open up. Under the Host Name section, type in the IP Address that has been emailed to your email and use SSH for the connection type. After entering these in, click “Open”.
  4. A new command window will open. Login as “pi“, press Enter, and then type the password “neurobionics” and press Enter.

Connecting to Raspberry Pi on Mac Computer After First Connection

  1. Connect Raspberry Pi to a power source.
  2. Open up Terminal application.
  3. Type in “ssh pi@<IPAddress>“, using the IP Address that was emailed to you and press Enter.
  4. Type “neurobionics” as the password and press Enter.

Shut down the Raspberry Pi

  1. In the command line of Raspberry Pi, type “sudo shutdown now” and press Enter.
  2. Wait until the led stop flashing, then you can unplug the power source.
  3. Note that unplug directly when the Raspberry Pi is on might damage the Raspberry Pi or the image file.

Testing Base-Line Code on the DEPHY Actuators

The page that is linked will walk take you back to the initial controls page. The baseline code will ensure that the computer, Raspberry Pi, and DEPHY actuators are communicating correctly. All the code that will be is downloaded on the SD Card from the initial image download. Click here to be routed to the page.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK