CASP RGPIO Aries Eco ESP01-WiFi Example

 

This project demonstrates how to use CASP Remote GPIO (RGPIO) to control pins on Vega Aries Eco target though ESP01-WiFi communication. Similar procedure may be followed for other targets supporting RGPIO through ESP01-WiFi communication. For details on RGPIO please refer CASP documentation. For demonstration purpose the target board pins are controlled through two approaches.

·       From CASP block diagram model

·       From Python

 

CASP Block Diagram Model Logic

The model shows following simple logics

·       Blink Aries Eco on-board blue LED at desired frequency settable at run time.

·       Display digital input value at pin-GPIO8

·       Plot ADC input value from pin-A1

·       Control digital output on pin-GPIO2

·       Control PWM output on pin-PWM2

·       Control servo connected to pin-PWM7

Python Based Logic

The Python file along with pin definition file are located in the ‘python’ folder of the project directory. The Python code implements following logic,

·       Display ADC (pin-A1) and digital input pin (pin-2) values

·       Blink on-board blue LED

·       Toggle digital output pin-GPIO8 value

·       Vary PWM value at pin-PWM2

·       Vary servo angle at pin-PWM7

 

Installing CASP And Required Components

The following steps may be followed to quickly run this example

·       Install CASP along with BSP for Vega Aries Eco. Run CASP. From main tool bar goto Tools -> CASP Python Libraries and click on ‘Install/Update’ to install CASP Python libraries.

Preparing Aries Eco For Supporting CASP RGPIO

·       Connect Aries Eco to the host computer on which this example project was running.

·       Within CASP open the project.

·       From main tool bar click ‘Setup Simulation’. In ‘Setup Simulation Parameters’ window ensure the RPGIO Pin Source is set to ‘rgpio_vega_aries_eco_esp01_wifi.pins’. Click RGPIO Settings ‘Configure’ button and set ‘Remote IP/MAC’ as 192.168.2.1. Click OK to close Remote GPIO Settings window and click Save and Close to close Setup Simulation Parameters window. Please refer below figure for better understanding.

·       On the Aries Eco board temporarily remove the BOOL SEL jumper and reset the board. From CASP main tool bar select Tools tab and click on Programmer button. Follow the steps mentioned in below figure to program Vega Aries Eco. After the board is programmed re-insert the BOOL SEL jumper and re-power the board.

       

·       Connect ESP01 WiFi module to Aries Eco board as shown in below figure.

       

·       Connect suitable peripherals such as LDR or IR distance sensor to pin-A1, limit switch to pin-GPIO8, external LED or relay module to pin-GPIO2, DC motor driver module to pin-PWM2, servo to pin-PWM7 etc of Aries Eco.

·       On your host PC, open WiFi settings and connect to ‘CASP_RGPIO’ WiFi network with password ‘0000000000’.

 

Running the CASP Model

·       Things are now ready, just open the project in CASP as mentioned above, and click on Run button to build and run the project. Simulation Panel window should start and start communicating with the board as shown in below figure

Running Python Example

·       Close the above window and run terminal or command prompt in ‘/rgpio_aries_eco_esp01_wifi/python’ folder. Type python or python3 with ‘rgpio_from_pc.py’ as argument and press Enter key. The Python code should start communicating with the board and execute the implemented logic.

     

References

Visit https://aadhuniklabs.com/casp-blog for various examples on CASP.