-
Notifications
You must be signed in to change notification settings - Fork 13
6. Arduino Simulation
Description of the decision process and implementation of Proteus Arduino simulation with Bluetooth library.
In order to develop and test Arduino code intended to control the glove vibrator motors, the following simulation environment is proposed.
Multiple environments were considered, with the following issues.
- Arduino IDE (https://www.arduino.cc/en/Main/Software): Does not support simulation, only compilation of code and deployment to physical Arduino PCB.
- Code::Blocks Arduino IDE (http://arduinodev.com/codeblocks/): Does not have Bluetooth library, seems to only support execution on virtual stock Arduino.
The following is a very powerful, full-fledged circuit simulation environment with support for BT modules (HC-05/06), any Arduino model (nano/micro/uno...) with Arduino source code deployment (accepts the path of "*.elf" binaries and runs them on the virtual Arduino), and BT emulation over COM port.
- Proteus (https://www.labcenter.com/downloads/): Not free (hacks easily available here: https://wle.ir/hadi/4-Program/Proteus/P85SP0/P85SP0.rar). SUPPORTS Bluetooth module simulation
- Virtual Serial Port Emulator (http://www.eterlogic.com/Products.VSPE.html): Allows the pairing of COM ports to enable communication between BlindAid (using CSerial class), and Proteus Virtual BT module. (Not free, but does not expire and offers all needed functionality).
- Eltima Virtual Serial Port Driver (https://www.eltima.com/products/vspdxp/): Not free (14 day trial).
- Free Virtual Serial Ports (https://freevirtualserialports.com/): Not free contrary to its name (extremely limited from day 1).
- CSerial Class (https://www.codeguru.com/cpp/i-n/network/serialcommunications/article.php/c2503/CSerial--A-C-Class-for-Serial-Communications.htm): Provides functions to connect/read/write data on a Serial Bus from a C++ application, only a single header and include file.
- Ramon de Klein Serial Library (https://www.codeproject.com/Articles/992/Serial-library-for-C): Way too sophisticated for our purposes, needs to be compiled linux-style.
Proteus is the ideal simulation environment due to its greater sophistication and maturity (ability to design complete circuits from scratch), and though it is not free it can easily be cracked. The following steps must be taken to make Proteus ready to use.
- Arduino Pro Micro Library+Models downloaded here: https://github.com/cyberponk/Arduino-Library-for-Proteus (other models here: https://www.theengineeringprojects.com/2015/12/arduino-library-proteus-simulation.html)
- Bluetooth HC-05/HC-06 Library downloaded here: https://www.theengineeringprojects.com/2016/03/bluetooth-library-for-proteus.html
- License key (crack) for version 8.5 downloaded here: https://wle.ir/hadi/4-Program/Proteus/P85SP0/P85SP0.rar
The goal of this simulation is to have a working circuit that accepts commands from a paired Bluetooth device, and successfully controls virtual vibrator motors. The basic components I see are as follows:
- Bluetooth communication protocol/commands shared between Platform and Arduino.
- Power delivery system (5V for Arduino + 3.7V for motors).
- Bluetooth module hardware connection + software communication accepting commands from paired device.
- Software loop that parses control commands from paired device and modulates vibrator control voltages accordingly.
A paired bluetooth device (eg. Arduino) shows up to a Windows host as a serial (COM) port device once it is paired. Assuming that the device has already been paired (once-and-for-all), BlindAid will simply need to integrate serial communication, and develop the proper commands following whatever the chosen serial protocol.
- Thus the only library dependency required to connect the BlindAid code to a bluetooth paired device will be a Serial communication class/library, such as one of the following: https://www.codeguru.com/cpp/i-n/network/serialcommunications/article.php/c2503/CSerial--A-C-Class-for-Serial-Communications.htm, https://www.codeproject.com/Articles/992/Serial-library-for-C
- There also seems to be another way, using Windows Bluetooth Socket Stack, but this seems much more complex (may be useful in establishing connections/pairing?): https://msdn.microsoft.com/en-us/library/windows/desktop/aa362928(v=vs.85).aspx
- Communication with the Proteus virtual HC-05 BT module is done via COM serial ports, there is no emulation of a true BT connection. Thus, we will only be able to implement Control simulation from BlindAid through a serial communication API class.
- It seems as though on the Windows PC side, a bluetooth connection to an Arduino will show up as a COMP port in Realtime anyway, so regardless of whether we are using the simulation OR a physical BT module, the connection method MAY end up being roughly the same.
- in Realtime an additional act of PAIRING the Arduino and PC will be required, but I don't think this will involve code (the user manually pairing - hopefully only one - will be a prerequisite to the software working).