Open Led Software Download for Mac
Introduction
The ROBOTIS OpenCM is a development Software and download tool for the OpenCM9.04 embedded board.
Sources of the ROBOTIS OpenCM are released under licenses of their respective authors.
Copyright (c) ROBOTIS Co., Ltd. Modified or newly-created codes are released under the GNUGPL or LGPL licenses.
For more information on the OpenCM9.04 refer to the Appendix department of the e-manuals.
Alert : OpenCM IDE is not updated anymore. It is recommanded to use Arduino IDE as OpenCM IDE isn't maintanined anymore.
ROBOTIS OpenCM Software Download
OpenCM9.04 uses the ROBOTIS OpenCM Integrated Developmental Surround (IDE) to allow users to programme with ease.
The download link for the ROBOTIS OpenCM IDE can be establish below:
- [Windows XP, Vista, vii, 8] 32bit/64bit : Download
- [Mac OS Ten] Tested in OS Ten 10.12.2 : Download
- [Linux 64bit] Tested in Ubuntu 12.04 : Download
- [Linux 32bit] Tested in Ubuntu 10.10 : Download
Getting Started
Install Software
Windows
Prepare the OpenCM9.04 and USB cable
For the cable you must fix an Android phone/pad Micro-B type USB cable. (This is included as a component of the bundle for the B type, and for the A type you must purchase through an accessory kit. Android smartphone cable is supported.)
Micro-B USB cable : same equally Android smartphone
Download the Windows release for ROBOTIS OpenCM IDE
Download the latest version from the ROBOTIS East-transmission(back up.robotis.com) site and unzip the file in an acceptable directory, which will contain the execution file ROBOTIS_OpenCM.exe and the USB commuter folder(\drivers) every bit shown beneath.
Directory structure after unzipping the file
Note that the ROBOTIS OpenCM is a portable program that but needs to be unzipped and executed without the need for any dissever installation process. If yous wish to remove the program, you merely demand to delete the directly fully.
Connect the OpenCM9.04 to the PC
For the installation of the USB driver, only connect the OpenCM9.04 to the PC using the USB cable equally shown below.
Figure 2.4.one-4 Connecting the OpenCM9.04 to the PC
However we do recommend you avoid connecting to a USB hub that is in utilize with many other USB devices, and instead you connect to the PC directly. At that place can exist rare cases in which if there is not enough electric current from the USB hub then the download can fail.
Driver Installation
For Window eight or x, get to "PC settings -> Update and recovery -> Recovery -> Advanced startup -> Troubleshoot -> Avant-garde options -> Startup Settings -> Restart -> Select 7) Disable driver signature enforcement, and and so restart" and and so install using Run as administrator.
In the previous step, connecting the OpenCM board to the PC will make a device called "ROBOTIS Virtual COM Port" appear in the Device Director.
Right-click on that device and select "Update Driver Software".
Adjacent select "Browse my figurer for driver software".
Click on "Browse" and select the directory that yous unzipped to a higher place(ROBOTIS\drivers).
Click Next and the installation proceeds.
If the USB commuter is installed successfully, a message will announced that says "Windows has successfully updated your commuter software" as shown below.
At this stage information technology is of import to check in the Device Manager what COM Port number the ROBOTIS Virtual COM Port has just been installed as.
Connecting to another USB port may modify the COM Port number so if you connected to another port then check over again and go along to download.
Run ROBOTIS_OpenCM.exe
In the unzipped directory(\ROBOTIS) double-click on the file ROBOTIS_OpenCM.exe.
This will execute the ROBOTIS OpenCM tool as shown below.
Open the Case Blink
Go to File → Examples → 01.Basics → b_Blink
Select the Board
In Tools → Lath, select ROBOTIS OpenCM9.04.
Select the Series Port
Make sure you select the COM Port number that you checked in the previous step.
Proceed to Download
Click on the Download button as shown below. Every bit the download begins the board'southward green LED is continuously turned on. Once the download is consummate the board resets and the Blink example is executed, and the LED blinks.
Note : If the power turns on for the lath and the green LED is continuously turned on and then restart the Download. Please refer to the Emergency Recovery Mode(Strength Download) section.
MAC Bone Ten
Download the Mac Bone 10 release for ROBOTIS OpenCM
Download the installation image file(dmg) for Mac Bone X from the East-manual.
When the download finishes, double-click on the dmg file below and proceed to Mount.
After mounting, when an installation window appears, click on the Robotis icon with the mouse and drag information technology to Application.
Then the installation will go along as below.
Run the ROBOTIS OpenCM
Using Finder, look in the Application folder to find the ROBOTIS.app application bundle and double-click on it to run the program.
As in the figure beneath, select the Open up push.
The ROBOTIS OpenCM is executed as shown below.
Open the Example Blink
Go to File → Examples → 01. Basics → b_Blink
Select Board
Select ROBOTIS OpenCM9.04.
Select Serial Port.
Select tty.usbmodemXXX. The number on the finish is unlike for each PC.
Keep to Download
Click on the Download button every bit shown below. Every bit the download begins the board's green LED is continuously turned on. Once the download is complete the board resets and the Glimmer case is executed, and the LED blinks.
NOTE : If the board'due south green Status LED does not plow on even subsequently clicking on the Download push, printing on the User button and while keeping the button pressed connect the USB to the PC.
Notation : If the power turns on for the board and the green LED is continuously turned on and then restart the Download. Please refer to the Emergency Recovery Manner(Forcefulness Download) section.
Linux
Download the Linux release for ROBOTIS OpenCM
If the Linux yous are using is 32bit then download the Linux 32 fleck bundle, and if information technology is 64bit then download the Linux 64 bit package from the e-Manual.
After downloading, use the following command to unzip the file. The description beneath is an example for when using 32bit.
If y'all unzip the file information technology volition create a ROBOTIS folder equally shown below.
Install JRE(Java Runtime Surroundings)
Same as for Arduino, the ROBOTIS OpenCM tool is a program that has been developed using Java and therefore requires JRE(Java Runtime Environment). The Windows packet includes JRE inside but the Linux version does not include it.
If it is installed then proceed to the next pace. The way to cheque if JRE is installed is to use java –version in Terminal as shown below.
If you go a message as in a higher place so you need to install Java JRE(Java Runtime Environment) or JDK.
Here is how yous install openjdk-seven-jre-headless.
$sudo apt-go install openjdk-7-jre At present that Java JRE has been successfully installed, you can run ROBOTIS OpenCM.
Install i386 Library (Linux 64bit)
In order to use in Linux 64bit OS, y'all need to install ia32-libs.
$sudo dpkg –add-architecture i386 $sudo apt-get update $sudo apt-go install ia32-libs If the installation completes successfully, the Processing trigger runs properly as shown below.
Run ROBOTIS OpenCM
As shown below, double-clicking ROBOTIS_OpenCM or entering ./ROBOTIS_OpenCM in Last and pressing Enter will run the program.
Click on the Execute push.
Then the program volition run as shown below.
Open the Instance Blink
Go to File → Examples → 01. Basics → b_Blink
Select Lath
In Tools → Board, select ROBOTIS OpenCM9.04.
Select Serial Port
The serial port is shown equally ttyACMX, where X is a unlike number for each PC.
The Linux/Mac OS 10 releases have the USB CDC Driver included in the kernel, and then unlike the Windows release you can run the program correct abroad without the need to install a driver separately.
Keep to Download
Click on the Download button equally shown below.
Equally the download begins the board's green LED is continuously turned on. Once the download is complete the lath resets and the Blink example is executed, and the LED blinks.
Annotation : If the lath's green Status LED does not plow on even afterwards clicking on the Download push button, press on the User button and while keeping the push button pressed connect the USB to the PC.
NOTE : If the power turns on for the board and the green LED is continuously turned on so restart the Download. Please refer to the Emergency Recovery Mode(Force Download) section.
Run Plan
If you lot run the program the following screen appears.
| Particular | Description |
|---|---|
| Carte du jour | You lot tin can select from File, Edit, Sketch, Tools, and Help. |
| Toolbar | You lot can select from a list of shortcut icons of often used functions. |
| Executes but the compilation and prints a message on the status bar or console stating whether it was fail or success |
| Executes compilation and proceeds to download right away. Make certain the board is connected when using this function |
| Creates a new file |
| Opens a file |
| Saves the electric current file |
| Runs the series monitor |
| Editor | This is the field where you lot edit the source. |
| Status Bar | This is the field where information technology shows the progress of the requested function visually. |
| Console | Shows the current cursor location's line number and the selected lath and COM Port. |
| Tab Menu | This is the menu that you select when adding or removing a tab. |
A Wait at Some Examples
The ROBOTIS OpenCM IDE provides some simple examples of functions provided by the OpenCM hardware board, and you tin check the File (east.g.)Examples menu to see the various examples shown beneath.
Lawmaking Editing Role
Auto Highlight Role
When typing code, registered keywords volition be highlighted in yellow or blueish automatically (as opposed to the usual blackness) as shown below.
Registered API will change colors as shown below, so that you can check if the proper noun of the API y'all are trying to use is typed correctly.
You tin also alter or add to the Automobile highlight part at any time in the keyword.txt file located in the directory beneath.
Using the Auto Format Function
Past using the function in Tools → Machine Format, codes that take been typed jumbled or messy are automatically organized neatly.
Codes such as below are automatically organized neatly past pressing Ctrl+T.
Adding and Removing Comments
Select Edit → Annotate/Uncomment as shown below or printing the hotkey Ctrl+/ to comment the unabridged line, and press the hotkey again to uncomment the line.
If you select a block as shown above and and so press Ctrl+/ it volition annotate the entire block as shown below.
If you lot press Ctrl+/ again information technology will uncomment the selected lines.
Increment and Decrease Indent
If you lot select Edit → Increase Indent/Decrease Indent yous tin command the indentation level from the electric current cursor. You lot can as well printing the hotkeys Ctrl+} to motility one tab to the right, or press Ctrl+} to move i tab to the left.
Pressing Ctrl+} repeatedly will move the cursor to the right ane tab at a fourth dimension equally shown beneath.
Compile and Download
Later on y'all write your code information technology is useful when programming to utilize the Compile menu in guild to check that the code yous wrote is grammatically correct and has no errors.
If the build is successful and then in the condition window beneath in the build's binary size section it will prove the maximum binary size, and the share proportional to the size every bit 0%.
If you have modified the codes in the Core directory shown below, y'all must delete the Object files that were previously created.
ROBOTIS\hardware\robotis\cores\robotis
Practice this past selecting the Tools → Make clean Objects menu and then build again. Information technology will take a long fourth dimension to build the start time, only from the second time on it will be fast again since it will reuse the Object files from the offset build.
The Object files are saved in each respective board directory inside the Core directory shown beneath.
If the whole code is compiled properly with no errors you tin now download. Simply click on the downwards arrow and it will compile and download all at in one case.
When the download finishes successfully there will be a bulletin that says Done downloading in the status bar and the downloaded code volition exist executes directly in OpenCM9.04.
Using the Series Monitor
ROBOTIS OpenCM provides a concluding program, similar to Windows'due south hyper concluding or TeraTerm, by default every bit an Add-on program.
If you lot wish to communicate with the selected COM1 port so click on the series monitor icon located on the upper-right side of the toolbar to open up the serial monitor. You can too use the hotkey Ctrl + Shift + Thou to open the series monitor.
Precautions Regarding the Serial Monitor
When OpenCM9.04 is downloading, USB communication will not exist available. Do not open the serial monitor when downloading is in progress. ( If information technology is a unlike COM port so it does not thing.)
Preferences
Manage your settings preferences in File → Preferences.
-
Sketchbook location : This is the user's default work directory. Sketch files will be saved and opened from this directory.
-
Editor language: This changes the font of the program to a different language.
-
Show verbose output during : If you cheque Compilation then it will show a detailed output during the compilation process.
If you check Download so it will show a detailed output of the download process, after the compile has finished.
Compile and download can go slower when using this pick, and so nosotros recommend you practice non use it unless it is essential to use it.
Libraries
Installing Libraries
The installation method of libraries is the same as for Arduino. The library's path is within the IDE folder equally libraries. ( ROBOTIS\libraries)
In the instance of Mac, access the path below. Documents/ROBOTIS/libraries
As in a higher place, organize the libraries folder so that inside there are files RC100.cpp, RC100.h with the same name every bit the folder RC100. You lot can put in lawmaking written with C file in the utility folder.
The examples folder is for sketch examples composed of the respective library. Examples are as well organized equally folders, and the folder name and the ino file name must exist the same to exist recognized.
Recovery Mode
If you are unable to download and the bulletin "Board is not responding" shows upwardly, please attempt using the recovery mode to forcefulness the download.
If you force the download once, the board should be recovered and normal downloads will be possible over again.
Hold down the User Push button on the OpenCM9.04 and connect the board to a PC using an USB cable.
Please have whatever other power source asunder, and just connect to the USB while having the User Button held down.
Hold downward the User Button when entering recovery manner.
When successful, the green LED should stay on as shown in the image below. When the download is completed the board will reset and the LED will plow off.
If unable to download, you must remove whatsoever code that may disturb the USB interrupt in the code you lot wrote.
Examples
EEPROM(Wink)
In the CPU of EEPROM(Flash) Library OpenCM9.04, which is STM32F103CB, there is a 128kbyte flash retentivity.
The flash memory is where nosotros save the programming in binary format and besides run information technology. The flash memory is a non-volatile memory and so even if the ability is turned off the saved data does non disappear.
However flash reads and writes data by unit of a folio and then it can be relatively inconvenient for saving one or 2 bytes.
However its speed is fast. Therefore in OpenCM9.04 we take created a dissever library chosen the EEPROM emulator to save user information in the unit of bytes.
Example
#include "EEPROM.h" int i ; EEPROM CM9_EEPROM ; void setup (){ CM9_EEPROM . begin (); Serial2 . begin ( 57600 ); Serial2 . println ( "##### Start OpenCM9.04 EEPROM Memory Test ##############" ); } void loop (){ delay ( 1000 ); for ( i = 0 ; i < x ; i ++ ){ Serial2 . print ( "EEPROMExample = " ); Serial2 . println ( CM9_EEPROM . read ( i ), HEX ); // read data from virtualaddress 0~9 } if ( Serial2 . available ()){ Serial2 . read (); Serial2 . println ( "******************EEPROM Writing Start *******************" ); for ( i = 0 ; i < 10 ; i ++ ){ CM9_EEPROM . write ( i , i * 2 ); // write i * 2 to virtual address 0 ~ 9 } } } If yous compile the lawmaking to a higher place and download information technology, it will read the values of the EEPROM virtual addresses from 0~ix through Serial2 as shown below.
Since there are no information all values will exist printed as 0xffff.
In contrast with the BKP, the initialization of the flash memory volition set all bits to ane.
Therefore 0xffff is printed. And pressing any key will input a value between 0~12 to the virtual addresses 0~9.
Now press the Reset button to restart.
At present we unplug the power and plug in again to check.
Sensor Module
All Robotis sensor modules can be connected to five-pivot ports. Delight refer to the OpenCM9.04 Hardware Transmission for the connection method.
For the A-blazon you volition need to separately solder the 5-pin connector, but for the B-type and C-blazon the 5-pivot connector will already be embedded.
Delight note that the pins assigned to the 5-pin are also shared with the 40-pivot IO on both sides, so in the header you must not use the IO pins assigned to the ports used below.
For case, if you connect the IR sensor to Port 1, you must non utilize Pins 2, half-dozen, and 7 in the header.
IR Sensor Module
-
Connectivity
The manner it works, as explained in the E-transmission, is if Loftier is given to SIG2(MOT+), the transmitter LED is turned on and its infrared is detected by the detector LED and is shown as ADC.
Information technology is recommended that you connect the infrared sensor module to the Ports 1, 4 of SIG2 that have a transistor excursion. Ports ii, 3 volition have a depression ADC value.
The figure beneath shows when it is connected to Port 1. The direction for the connector is to connect the gray cord to the USB.
You can read the maximum value of the ADC value if you read information technology after approximately ten~15us. And the properties of the ADC values that can be detected co-ordinate to their distance are shown below, so this must be taken into consideration for utilize.
It is not possible to detect objects that are further than 15cm and object that are as well close volition reflect the infrared and the angle entering the detector LED volition not exist valid and effect in a section that the sensor values will fall.(This corresponds to the section between 0~one.5cm) -
Confirming Operation
Open up ROBOTIS OpenCM's Example –> 07. Sensors –> IR_Read.
After downloading, open the serial monitor and place the object(maximum when white) close and you will be able to see the ADC values every bit shown below.
-
Operation Code
The IR sensor can perform IR sensing as long as it controls the pin that corresponds to the SIG2 and the ADC port. The OLLO library is already coded with this principle.
Cheque that Pins two, 6, 7 are assigned to Port one. In setup(), initialize Pins 6, seven that are assigned to SIG1,2 to LOW and initialize Pin ii to analog input.
In function readIR, fix SIG2(Pin 7) equally HIGH to plough the transmitter LED as ON and if yous read the analog value after 15us y'all tin read the optimal ADC value.
And if you send SIG2 again every bit LOW so ane cycle will be finished. It does not matter if at that place is cypher 30us after.
The OLLO library is already coded with this principle then yous can hands employ it.
DMS Sensor Module
-
Connectivity
By default, you lot corroborate voltage using the 3 middle pins of the 5 pins and later on read the ADC value to utilize it.
It has the reward that fifty-fifty if the colour and reflectivity change compared to the infrared sensor, there is virtually no change to the output value respective to the distance.
There is no difference connecting to any of the 5-pin sensor ports of OpenCM9.04.
The DMS sensor does not use SIG1, ii so it does non distinguish ports. Below it was connected to Port ii and the example code is explained based on Port 2. -
Confirming Performance
In File –> Examples –> 07. Sensors, you tin download case OLLO_DMS_Read and bank check using the series monitor.
-
Functioning Code
Sensors such equally the DMS sensor module which are comprised of 3 pins from the v pivot only need to keep on Reading the analog input. They practise not need a dissever initial lawmaking.
Gyro Sensor
-
Connectivity and Sensor Internal Structure
The Robotis gyro sensor tin also exist continued to Pin 5 of OpenCM9.04 to measure out the angular speeds of X, Y (rotational acceleration).
Connect the gyro sensor module of OpenCM9.04 to Pins 1 and two of the 5-pin port. Connect the Ten-axis pint to Port 1 and the Y-axis pivot to Port 2 every bit shown in the connectivity below.
-
Operation Code
Download from Examples -> 07. Sensors -> OLLO_Gyro_Read and open up the series monitor to bank check the rotational acceleration of the X- and Y-axis in ADC as shown below.
Initialize Port ane continued to the 10-axis pivot and Port 2 continued to the Y-axis pin and in the loop, read the ADC value of the rotational dispatch of the X- and Y-axis in a 60ms cycle.
Every bit for the DMS sensor module, y'all simply demand to read the analog pin value from the loop.
LED Module
-
Connectivity and Internal Structure
The LED module is not a sensor module but simple a module to use 2 LED's as a display format.
By looking at the circuit diagram yous can tell that it is existence controlled in a Electric current Sink method where MOT+- volition exist OFF when HIGH, and ON when LOW.
The SIG2 pins of Ports 1 and four of OpenCM9.04 does not turn Low so there is a brake in using the LED module, so utilise Ports 2 and 3 of the five-pin ports. The effigy beneath shows an example of using Port 3 to connect the LED module. -
Confirming Operation
In File -> Examples -> 07. Sensors, download and run case OLLO_LED_Blink and you will see that both LED's from each side will blink alternatively.
The LED module does not need the ADC pin so you only need to employ pins SIG1 and two. You can employ the LED module by initializing Port 3 in setup() every bit shown below.
Touch Sensor
-
Connectivity and Internal Structure
The impact sensor works past detecting whether it has been touched, but as a button, when information technology is simply pressed from the acme. Y'all can also use it simply as a push button.
The circuit diagram is likewise zero more than a frequently used button circuit. When the button is pressed it returns HIGH and when the button is released information technology returns Depression.
Yous connect information technology to Port ii of OpenCM9.04. -
Operation Code
Download OLLO_TOUCH_Read from the OLLO library and open up the series monitor to check the issue. i ways the button is not pressed, and if the button is pressed than the value 0 will be output.
The touch sensor only uses the middle 3 pins of the v pins too. We recommend using the ADC pin by declaring information technology as a digital input.
Since the touch sensor does not have an internal Pull-downward circuit yous must define INPUT_PULLDOWN as a Pull-downwardly option. The OLLO library volition internally initialize the pins of the v-pivot sensor in this way.
Digital I/O
Connect the LED to Pin 13.
Connect the LED and resistor to OpenCM9.04 every bit shown beneath. Connect to Port 13.
For digital output yous must utilise pinMode(13, OUTPUT) in setup() to set Pin 13 as OUTPUT. And use the function digitalWrite() to assign Loftier/LOW value.
digitalWrite ( 13 , High ); //Outputs HIGH to Pin thirteen. digitalWrite ( 13 , LOW ); // Outputs LOW to Pin 13. When Pin 13 is assigned as LOW, information technology becomes a GND(negative concluding) and an electric current is formed so the LED turns on. On the contrary, if Pin 13 is assigned every bit Loftier it becomes iii.3V and there is no electric electric current formed then the LED turns off. This is the principle by which y'all tin can write a sketch code that will make the LED blink.
void setup (){ pinMode ( 13 , OUTPUT ); } void loop (){ digitalWrite ( xiii , HIGH ); delay ( 100 ); //delay of 0.1 second digitalWrite ( 13 , LOW ); filibuster ( 100 ); //delay of 0.1 second } Yous will see the LED blink every 0.1 second.
Permit us make the Condition LED glimmer.
In OpenCM9.04 y'all can fifty-fifty test using the greenish Status LED built-in to the board without having to connect the LED as in the case above.
The Status LED is connected to Pin fourteen and you lot can use the predefined function BOARD_LED_PIN to control it. This provides the advantage that if you write a sketch code using BOARD_LED_PIN then even if the board is inverse you do not take to alter the code.
Open an case file past selecting File –> Examples –> 01. Basics –> b_Blink_LED.
If y'all download it then the green Status LED will blink.
Let us receive a digital input in Pin 7.
Connect the push and pull-down resistor every bit shown below. Use Port 7 to receive the digital input.
For digital input on the I/O Pin of OpenCM9.04 y'all must use pinMode(7, INPUT) in setup() to configure Pivot 7 as INPUT. Then receive Loftier/LOW values with the function digitalRead() as shown below.
int value = digitalRead ( 7 ); // Reads Pin 7 and assigns it to the variable value Now it checks with the unabridged code. If the button is pressed then HIGH will be detected, and if the switch is separated then LOW volition be detected.
The reason why Low is detected when the push is separated is considering in that location is a GND continued to the pull-down resistor
void setup (){ pinMode ( 7 , INPUT ); SerialUSB . brainstorm (); } void loop (){ int value = digitalRead ( vii ); if ( value == Loftier ) SerialUSB . println ( " HIGH Detected ! " ); else SerialUSB . println ( " Depression Detected ! " ); delay ( 100 ); } If you lot change the excursion higher up to a pull-up excursion as shown beneath, information technology will piece of work in the opposite way. If the button is pressed then Low will be detected, and if information technology is separated then HIGH will be detected. The reason why HIGH is detected when the button is separated is because at that place is a 3.3V voltage connected to the pull-upward resistor.
Allow us receive digital input without either pull-upwards or pull-downwardly resistors.
In OpenCM9.04 it is possible to configure a switch circuit in digital input without a pull-downwardly or pull-upward resistor. The 26 GPIO Pins in OpenCM9.04 have internal input Pull-up/Pull-downwardly resistors that you lot tin configure with the software.
If you need an internal pull-up you lot can configure as pinMode(7, INPUT_PULLUP) and if you demand a pull-downwards circuit you can configure equally pinMode(7, INPUT_PULLDOWN).
If y'all ascertain as INPUT then it would mean digital input made as floating so there will demand to exist an exterior pull-up or pull-down circuit. Let us look at an example.
The circuit shown below is a circuit that receives digital input through Pin 7 only the button is directly continued to GND. In this case we can define Pin 7 as INPUT_PULLUP in order for the button to work normally.
In this example if the button in pressed and so Low will be detected, and if the switch is separated and then HIGH will be detected due to the internal pull-upward.
void setup (){ pinMode ( 7 , INPUT_PULLUP ); SerialUSB . begin (); } void loop (){ int value = digitalRead ( seven ); if ( value == HIGH ) SerialUSB . println ( " HIGH Detected ! " ); else SerialUSB . println ( " Low Detected ! " ); filibuster ( 100 ); } For the opposite case connect the button directly to the 3.3V as shown in the connectivity beneath.
In this case if the button is pressed then Loftier will be detected, and if the switch is separated then LOW will be detected due to the internal pull-down.
void setup (){ pinMode ( vii , INPUT_PULLDOWN ); SerialUSB . brainstorm (); } void loop (){ int value = digitalRead ( seven ); if ( value == High ) SerialUSB . println ( " Loftier Detected ! " ); else SerialUSB . println ( " LOW Detected ! " ); delay ( 100 ); } Let us receive an input using the User Button.
Similar to the built-in Status LED, there is a built-in User Button that can be used without the need to make a split button circuit. If yous wait at the excursion diagram you tin can come across the built-in pull-down input being used.
The User Button is continued to Pin 23 and so you can designate Pin 23 directly or use BOARD_BUTTON_PIN.
void setup (){ pinMode ( BOARD_BUTTON_PIN , INPUT_PULLDOWN ); SerialUSB . begin (); } void loop (){ int value = digitalRead ( BOARD_BUTTON_PIN ); if ( value == High ) SerialUSB . println ( " High Detected ! " ); else SerialUSB . println ( " Depression Detected ! " ); filibuster ( 100 ); } If yous download yous volition run across that when the User Button is pressed then Loftier will exist input, and if the switch is separated then Low volition be input due to the internal pull-down circuit.
Let the states toggle the Status LED.
If the current output of Pin i is Loftier so information technology will change to LOW, and if it is currently LOW then it will change to High.
digitalWrite ( 1 , HIGH ); // Pin 1 which was HIGH will become Depression once again. togglePin ( ane ); // Pin i which was HIGH will become LOW once more. We can at present easily write the LED Blink example past using this principle. Let us simply use togglePin() with the Status LED.
void setup (){ pinMode ( BOARD_LED_PIN , OUTPUT ); // } void loop (){ togglePin ( BOARD_LED_PIN ); delay ( 100 ); //Delay 0.1 second } The LED will glimmer with a 0.i 2d interval. Note that using toggleLED() which only toggles BOARD_LED_PIN will attain the same actions.
Analog I/O
For analog input, it is of import to annotation that just Pins 0~9 located in the OpenCM9.04 silk screen'due south ANALOG IN area will support analog input. Analog output is substituted by PWM Output using TIMER.
Pivot 3 receives analog input past a variable resistor.
Connect a variable resistor to Pin iii and a voltage of three.3V as shown beneath.
For the analog input in Pin 3, use pinMode(3, INPUT_ANALOG) to configure the Pin Mode equally analog input and yous are now ready. Use analogRead() to read analog values through Pin 3 every bit nosotros configured.
int value = analogRead ( 3 ); // Reads analog input through Pivot 0 and assigns it to the variable value. Here the value that is assigned to the variable value is a 12bit ADC value betwixt 0 ~ 4,095. Let us output the ADC value that is read through the entire lawmaking.
void setup (){ pinMode ( 3 , INPUT_ANALOG ); } void loop (){ int value = analogRead ( iii ); SerialUSB . println ( value ); // allow u.s.a. output the value. delay ( 100 ); //delay fourth dimension for USB transfer } Let us perform analog output(PWM) to Pin half-dozen.
Nosotros can control the LED using PWM outputted to Pivot 6. Connect the LED and resistor using a breadboard and connect to Pin 6 as shown beneath.
Configure Pin 6 to analog using pinMode(6, PWM). Use analogWrite() to PWM Output to Pin 6 as configured.
Analog output is substituted by PWM Output. PWM's Duty cycle is controlled through the 2d statement. Here we have used the value 10000 but the duty wheel tin be set to a value between 0~ 65535. The value 0 represents a 0% duty cycle and the value 65535 represents a 100% duty cycle.
Now it checks the entire lawmaking.
void setup (){ pinMode ( 6 , PWM ); } void loop (){ for ( int i = 1 ; i < 7 ; i ++ ){ analogWrite ( half-dozen , i * 10000 ); //generate pwm as 10000 ~ 60000 scale delay ( 100 ); } } By controlling the second statement of analogWrite() we can implement PWM with a variety of Duty Cycles equally shown below.
Let us perform Dimming so that the Status LED will turn off slowly.
The Status LED is continued to Pivot 14 which is also capable of PWM output. Open up an case file past selecting File –> Examples –> 01. Basics –> f_Led_Fadin.
If you download to OpenCM9.04 information technology will make the Status LED repeatedly plow on and off slowly.
Serial Advice
OpenCM9.04 has a total of 4 series devices. There are Serial1, Serial2, Serial3, and SerialUSB, but Serial1 is assigned exclusively as DYNAMIXEL communication port so there are restrictions for using it. Serial 2 is for using Bluetooth devices with iv pin ports such equally BT-210 and BT-110A. Serial3 is shown at the back-side of the PCB as TX3(24), RX3(25).
The SerialUSB is very important in OpenCM9.04. It performs the firmware download for ROBOTIS OpenCM and as well performs information advice as do Serials ane,ii,3. The instructions to use it is near the aforementioned equally for Serials 1,two,3.
Let u.s.a. send information using a serial device.
Using LN-101 connect the 4 pin advice port to the PC as shown below. Use RoboPlus Terminal or a series monitor in the PC to open up the COM port.
You must perform an initialization for the Serial 2 device as shown below and then perform the following examples in loop().
void setup (){ Serial2 . brainstorm ( 57600 ); } void loop (){ //Test instance code } Sending data can be done using print() and println() methods, where the impress() method will print without changing lines and the println() method will print besides as modify lines.
Serial2 . impress ( " Hello World This is OpenCM9 . 04 " ); Permit united states of america print the "Hello World" string through the Serial2(TX2, RX2) device.
Serial2 . print ( " OpenCM9 . 04 is the showtime product of OpenCM Series " ); Serial2 . println ( " println () ends this line " ); Seirla2 . println ( " This is new line " ); println() will change lines and print every bit a new line. You can check the printing every bit shown beneath.
This will print 12 equally a decimal number.
int abc = 128 ; Seial2 . impress ( abc ); This will print the value 128 of variable abc.
This will print the value 128 of variable abc equally a hexadecimal value. 0x80 will be printed.
This will print the value 128 of variable abc as a binary value. In the same way, if you set the second argument as viii then it will impress as an octal value, and if at that place is no second argument so by default it will print as a decimal value.
This will print 3.14 as a Double blazon and then change lines. It will print to 2 decimal places. You can as well define a variable Double and and then print it.
double var = i . 234 ; Serial2 . println ( var ); This will impress the analog values read from Pivot 0, 1, and two through Serial ii in their corresponding order. If you use many print() and println() methods then you can print neatly as shown below.
int sensorValue0 = 0 ; int sensorValue1 = 0 ; int sensorValue2 = 0 ; sensorValue0 = analogRead ( 0 ); sensorValue1 = analogRead ( i ); sensorValue2 = analogRead ( ii ); Serial2 . print ( " Sensor0 = " ); Serial2 . print ( sensorValue0 ); Serial2 . impress ( " Sensor1 = " ); Serial2 . print ( sensorValue1 ); Serial2 . impress ( " Sensor2 = " ); Serial2 . println ( sensorValue2 ); At last If yous change lines by using the println() method only for printing sensorValue2 then you lot tin achieve a cracking printing of the 3 analog inputs.
Permit us receive data using a series device.
We volition implement an Echo office using a serial device. When information comes to the Serial 2 device through a char-type variable temp then we will save the information using the read() method and print correct away using the print() method to implement the Echo role.
char temp = 0 ; loop (){ if ( Serial2 . available () ){ temp = Serial2 . read (); Serial2 . print ( temp ); } } The unabridged code is shown below.
void setup (){ Serial2 . begin ( 57600 ); } byte temp = 0 ; void loop (){ if ( Serial2 . bachelor () ){ temp = Serial2 . read (); Serial2 . print ( temp ); } } Let us implement it in an interrupt driven method every bit shown below. The interrupt of a Serial device is configured as a function that does not take a return type and contains i byte-type argument. And here if we print the data given by the impress() method right abroad and then nosotros have implemented the Echo part. You tin implement and use in whatsoever location without separately defining a prototype.
void serialInterrupt ( byte buffer ){ Serial2 . print ( buffer ); } Inside setup() we can configure the implemented serialInterrupt() every bit a role pointer format using attachInterrupt().
Serial2 . attachInterrupt ( serialInterrupt ); The unabridged code for inputting information of Serial two using the interrupt is shown below.
void setup (){ Serial2 . begin ( 57600 ); Serial2 . attachInterrupt ( serialInterrupt ); } void serialInterrupt ( byte buffer ){ Serial2 . impress ( buffer ); } void loop (){ //Code is non necessary. } Let us print data using the SerialUSB device.
Utilise the Micro-B USB connector of OpenCM9.04 to connect straight to the PC as shown below. In this case we communicate with the PC only using OpenCM9.04 without any device such every bit LN-101.
You must perform an initialization for the SerialUSB device every bit shown below and so perform the following examples in loop(). There is no designation of Baud rate.
void setup (){ SerialUSB . begin (); } void loop (){ //Test example code } The instructions to use information technology is almost the aforementioned every bit for the Serial devices. You tin command information technology in the same manner by using print() and println() methods.
SerialUSB . print ( " CM - 900 is the commencement production of CM - ix Serial " ); SerialUSB . println ( " println () ends this line " ); SeirlaUSB . println ( " This is new line " ); `` This volition print 12 as a decimal number . ``` c SerialUSB . print ( 12 ); This will print through an int-blazon variable.
int abc = 128 ; SerialUSB . impress ( abc ); This time we will print the value of variable abc as a hexadecimal value.
SerialUSB . print ( abc , 16 ); This will print the value 128 of variable abc as a hexadecimal value, which is 0x80.
This will print the value 128 of variable abc as a binary value. In the same way, if you set the 2d argument as viii and so it will impress equally an octal value, and if there is no 2d statement then by default it will print as a decimal value.
This will print three.xiv every bit a Double blazon and then alter lines. It will impress to ii decimal places. You can also ascertain a variable Double and then print it.
double var = 1 . 234 ; SerialUSB . println ( var ); Let u.s.a. receive information using the Series USB device.
We volition implement an Echo office using the Serial USB device. When data comes to the Series USB device through a char-type variable temp so nosotros will save the data using the read() method and impress right away using the print() method to implement the Echo function.
char temp = 0 ; loop (){ if ( SerialUSB . bachelor () ){ temp = SerialUSB . read (); SerialUSB . impress ( temp ); } } The entire code is shown below.
void setup (){ SerialUSB . brainstorm (); } byte temp = 0 ; void loop (){ if ( SerialUSB . available () ){ temp = SerialUSB . read (); SerialUSB . print ( temp ); } } Let us implement it in an interrupt driven method as shown beneath. The interrupt of the Serial USB device is configured equally a function that does non have a return blazon and contains a byte-type argument and a byte* argument. And here if we print the data given by the impress() method right away and so we accept implemented the Echo part. If you write information to the USB COM Port through the PC'due south final information technology will transport i byte at a time so information technology is sufficient to prepare nCount =ane and Echo simply the Alphabetize 0 information of the buffer.
void usbInterrupt ( byte nCount , byte * buffer ){ SerialUSB . print ( buffer [ 0 ]); } Inside setup() we can configure the implemented usbInterrupt() as a part pointer format using attachInterrupt()
SerialUSB . attachInterrupt ( usbInterrupt ); We can exit the loop() role every bit an empty part every bit shown below.
The entire lawmaking for using the Interrupt of the SerialUSB device is shown below.
void setup (){ SerialUSB . begin (); SerialUSB . attachInterrupt ( usbInterrupt ); } void usbInterrupt ( byte nCount , byte * buffer ){ SerialUSB . impress ( buffer [ 0 ]); } void loop (){ //Code is not necessary. } External Interrupt
Permit us write a code that turns the LED off and on when the signal input to Pivot 7 changes. Connect the switch continued to the 3.3V to Pin 7 as shown below. We volition use the internal input pull-down option without using the external pull-down excursion. In the same fashion connect the LED and resistor to the iii.3V and so connect it to Pivot 13. Be cautious of the direction of the LED.
Let the states use a global variable to make a flag and use the method of toggling the flag in the interrupt routine whenever the signal from Pin seven changes.
volatile int state = Low ; In setup() we will configure the external interrupt with the attachInterrupt() function and ascertain the related Pivot 7 as INPUT_PULLDOWN in pinMode.
pinMode ( 7 , INPUT_PULLDOWN ); attachInterrupt ( 7 , LedChange , Alter ); We volition implement LedChange () as a void LedChange (void) type.
void LedChange (){ if ( state == Loftier ) state = Depression ; else country = HIGH ; } loop (){ digitalWrite ( BOARD_LED_PIN , country ); } The entire code is shown below.
DYNAMIXEL Instructions
DYNAMIXEL used in the example below volition exist under the premise that ID=1 and the advice speed have all been initialized to 1Mbps. Even though DYNAMIXEL class has non been defined explicitly, nosotros will assume that is has been predefined as shown below.
Dynamixel Dxl ( i ); // Dynamixel Bus on Serial1(USART1) Let us read the model number and firmware version of AX-12A.
In the E-manual the address value of the model number and firmware version in the Command Table is shown below.
In AX-12A, for which the ID number is 1, nosotros will read from address number 0 which corresponds to the model number's depression-order byte and from address number two which corresponds to the firmware version information. They are all i byte and then we tin use a byte-type variable.
byte nModel = Dxl . readByte ( 1 , 0 ); // First nosotros read the model number byte vFirmware = Dxl . readByte ( 1 , ii ); // Then we read the firmware version. We will print every bit beneath . SerialUSB . print ( " Model Number : " ); SerialUSB . print ( nModel ); SerialUSB . impress ( " Firmware Ver : " ); SerialUSB . println ( vFirmware );
Nosotros will read the internal temperature of AX-12A, for which the ID number is 1.
The accost value that corresponds to the internal temperature of AX-12A in the Command Table is shown below.
Using the same method we will read one byte using readByte().
byte temp = Dxl . readByte ( 1 , 43 ); SerialUSB . impress ( " Electric current Temperature : " ); SerialUSB . println ( temp ); Let us configure the ID as two for AX-12.
We will tape one byte in the accost number 3, which corresponds to DYNAMIXEL ID, using the method writeByte().
void setup (){ Dxl . begin ( 1 ); delay ( 1000 ); // It is good to give about ane second of delay. Dxl . writeByte ( i , 3 , 2 ); //Changes the ID number 1 of DYNAMIXEL to ID number 2 } void loop (){ Dxl . writeByte ( two , 25 , 1 ); //LED Blinking using the inverse ID number delay ( 100 ); Dxl . writeByte ( 2 , 25 , 0 ); filibuster ( 100 ); } If the change in ID number successfully finishes DYNAMIXEL's LED will blink.
Let us change the Baud Charge per unit to 57600 bps.
The advice speed of DYNAMIXEL can be changed by using the Baud rate in address number 4. Similar to alter the ID number nosotros will employ the writByte() method. If we employ DYNAMIXEL speed computation of 57,600bps then the alphabetize value comes out as 34. For DYNAMIXEL ii.0 protocol please refer to the new Baud rate tabular array - for 57600bps the alphabetize value will be i.
void setup (){ Dxl . begin ( one ); filibuster ( thou ); // Information technology is good to give about i second of delay. Dxl . writeByte ( 1 , 4 , 34 ); // 34 = 57600 bps Dxl . brainstorm ( 34 ); // Initializes to the changed Baud rate filibuster ( 1000 ); } void loop (){ Dxl . writeByte ( 1 , 25 , 1 ); delay ( 100 ); Dxl . writeByte ( 1 , 25 , 0 ); delay ( 100 ); } Since the Baud rate has been modified we need to initialize the Jitney again to Dxl.begin(34).
Let us bank check whether DYNAMIXEL for which ID number is 1 has moved or not.
We tin can check the current motion status of AX-12A by using the value 46(0x2E) in the Control Table.
byte bMoving = Dxl . readByte ( ane , 46 ); If DYNAMIXEL with ID number 1 is currently moving then the value 1 volition be returned for the variable bMoving, and if information technology is not moving then the value 0 will be returned.
Let u.s. motility the AX-12A DYNAMIXEL to a location of 150 degrees.
To move DYNAMIXEL to the desired location (150 degrees) we demand to input the desired location to the accost that corresponds to the Goal Position. Information technology is composed of 2 bytes (a low-order byte and a loftier-club byte) every bit shown beneath, and instead of accesses them individually nosotros recommend recording two bytes (1 word) to the low-society byte 30(0x1E) using writeWord().
In the E-transmission we can check that the location that corresponds to 150 degrees it matched to 512 as shown below.
Dxl . writeWord ( 1 , thirty , 512 ); Now check if the advice was successful using the function Dxl.getResult().
For each RX-64 let u.s. move them each to the following locations and speeds.
After nosotros stop moving them we will return them all to their original location of 0. This action will exist repeated continuously.
Permit us create a Sync Write packet data that nosotros volition send to each DYNAMIXEL. We will create a Sync Write bundle data for the 0 location and another packet data to save the goal position and speed.
#define PACKET_LEN 12 #ascertain NUM_OF_DATA 2 int SyncPage1 [ PACKET_LEN ] = { 1 , 010 , 150 , 2 , 220 , 360 , 3 , 020 , 170 4 , 220 , 380 }; int SyncPage2 [ PACKET_LEN ] = { 1 , 0 , 0 , ii , 0 , 0 , 3 , 0 , 0 four , 0 , 0 }; void loop (){ Dxl . syncWrite ( 30 , NUM_OF_DATA , SyncPage1 , PACKET_LEN ); delay ( thou ); Dxl . syncWrite ( 30 , NUM_OF_DATA , SyncPage2 , PACKET_LEN ); filibuster ( 1000 ); } Let u.s. restrict the movement angle to 0~150 degrees.
If the CCW Angle Limit is 0x3FF then it is 300 degrees, then we volition send 0x200 which corresponds to 150 degrees using the writeByte() method.
Circumspection : If you ready the CCW Bending Limit in number 8 to 0 and so information technology volition alter to wheel way and you lot will not be able to control the Goal position.
Dxl . writeWord ( one , 8 , 0x200 ); if ( Dxl . getResult () == COMM_RXSUCCESS ){ // Cheque if the communication was successful...} Let united states of america configure the movement voltage to 10V ~ 17V.
The data for 10V is 100(0x64), and the data for 17V is 170(0xAA), and then we use the writeByte() method for each of them to record the lower and upper limits. The Control Table addresses for them are lower-range voltage= 12(0x0C) and upper-range voltage = 13(0x0D) respectively.
Dxl . writeByte ( 1 , 12 , 100 ); Dxl . writeByte ( 1 , xiii , 170 ); if ( Dxl . getResult () == COMM_RXSUCCESS ){ // Cheque if the communication was successful...} Let us limit the torque to merely 50% of its maximum value.
We volition configure the MAX Torque value from its maximum value 0x3FF to l% which is 0x1FF. Nosotros will write the data to the Max Torque's lower-order byte address 14(0x0E) using writeByte().
Dxl . writeByte ( ane , 14 , 0x1FF ); if ( Dxl . getResult () == COMM_RXSUCCESS ){ // Bank check if the communication was successful...} You need to turn the power off and and then restart the ability for the Max Torque to modify.
Let us move to the Position of 180 degrees with speed 57RPM.
Moving Speed ( Address 32 ( 0x20 ) ) = 512 ( 0x200 ) Goal Position ( Address 30 ( 0x1E ) ) = 512 ( 0x200 ). We will admission data by units of words as shown below . Dxl . writeWord ( ane , 32 , 512 ); // Configure the speed as 57 RPM Dxl . writeWord ( 1 , 30 , 512 ); // Move to location 180 degrees if ( Dxl . getResult () == COMM_RXSUCCESS ){ // Cheque if the communication was successful...} Move ID #0 AX-12 to 0°, and move ID #i AX-12 to 300°
Nosotros will start with both AX-12 in the same position. Similar to Syncwrite, we volition create a Packets straight using the setTxPacketXXX() method. In this case nosotros will make a Packet using INST_REG_WRITE and INST_ACTION. Note that the location of ane degrees corresponds to 0, and the location of 300 degrees corresponds to 1023(0x3FF).
ID = 0 , Instruction = INST_REG_WRITE , Address = 30 ( 0x1E ), Information = 0 ID = 1 , Instruction = INST_REG_WRITE , Accost = xxx ( 0x1E ), Data = 1023 Dxl . setTxPacketId ( 0 ); // We specify the control of ID number 0. Dxl . setTxPacketInstruction ( INST_REG_WRITE ); Dxl . setTxPacketParameter ( 0 , 30 ); // Goal Position Address Dxl . setTxPacketParameter ( ane , Dxl . getLowByte ( 0 )); // Low Byte Dxl . setTxPacketParameter ( 2 , Dxl . getHighByte ( 0 )); // Loftier Byte Dxl . setTxPacketLength ( v ); //Total data length = Data length + 3 Dxl . txrxPacket (); if ( Dxl . getResult () == COMM_RXSUCCESS ){ // Check if the communication was successful...}
Sending packet for the 2nd DYNAMIXEL
Dxl . setTxPacketId ( 1 ); Dxl . setTxPacketInstruction ( INST_REG_WRITE ); Dxl . setTxPacketParameter ( 0 , thirty ); // Goal Position Address Dxl . setTxPacketParameter ( 1 , Dxl . getLowByte ( 1023 )); //Low Byte Dxl . setTxPacketParameter ( ii , Dxl . getHighByte ( 1023 )); //High Byte Dxl . setPacketLength ( 5 ); Dxl . txrxPacket (); if ( Dxl . getResult () == COMM_RXSUCCESS ){ // Check if the communication was successful...}
To execute the Instruction that was on standby in the registers of DYNAMIXEL number 0 and 1, send the Package INST_ACTION.
Dxl . setTxPacketId ( BROADCAST_ID ); Dxl . setTxPacketInstruction ( INST_ACTION ); Dxl . setTxPacketLength ( two ); Dxl . txrxPacket (); if ( Dxl . getResult () == COMM_RXSUCCESS ){ // Check if the communication was successful...}
Nosotros recommend checking if the communications was successful after creating and sending each Packet.
RC-100
How to connect OpenCM9.04 using RC100 by using OpenCM'southward RC100 library nosotros can command OpenCM9.04 remotely. Below you can see the various wireless connections that you tin make between OpenCM9.04 and RC100. The RC100 library will only work unremarkably if a communication model is continued to the 4 pin communication port of OpenCM9.04. Please refer to the RC-100 for information on the RC-100 communication package.
Bluetooth connection using RC-100B + BT-100 or BT-210
Connecting to the RC100 controller using Bluetooth
ZigBee connection using RC-100B + ZIG-100/ZIG-110A
Connecting OpenCM9.04 and the RC100 controller using ZigBee
Infrared connection using RC-100B + IR Receiver OIR-10
Delight refer to IR-10 for information on infrared communication methods for RC-100A or RC-100B.
Bluetooth connexion using an Android smartphone + BT-210
For Android smartphones you tin use the R+ grand.Task application's RC100 simulation to ship RC-100 packets. Yous can download R+m.Chore through Google Play.
Connecting OpenCM9.04 and your smartphone using Bluetooth – using the RC100 feature of R+m.Task
Let us make the Status LED of OpenCM9.04 glimmer when Push 1 of RC100 is pressed.
The RC100 library is used to process the RC100 packets in OpenCM9.04.
The RC100 library can be started in 2 modes, the wireless communication mode and the infrared communication fashion.
- Wireless communication fashion(1) : Bluetooth module(BT-210/BT-110A), ZigBee module(ZIG-110A)
- Infrared communication mode(2) : Infrared receiver(OIR-10)
Nosotros will initialize to the RC100 library using the wireless communication style.
#include <RC100.h> RC100 Controller ; Controller . begin ( one ); //RC100 init as remote mode Delight refer beneath for defining each push button of RC100.
#ascertain RC100_BTN_U (i) #define RC100_BTN_D (2) #define RC100_BTN_L (4) #ascertain RC100_BTN_R (viii) #ascertain RC100_BTN_1 (xvi) #ascertain RC100_BTN_2 (32) #define RC100_BTN_3 (64) #define RC100_BTN_4 (128) #ascertain RC100_BTN_5 (256) #ascertain RC100_BTN_6 (512) If the packet data read using the RC100 library is Button ane then output the Status LED to LOW.
if ( Controller . available ()){ RcvData = Controller . readData () if ( RcvData & RC100_BTN_1 ) digitalWrite ( BOARD_LED_PIN , LOW ); } The entire code is shown below, and you can open the same lawmaking past selecting File -> Examples -> RC100 -> RC100_LED_Control.
In the same way, we will make the Status LED glimmer using the OIR-10 Infrared receiver.
We volition initialize the Infrared communication mode to the number 2 as shown beneath.
#include <RC100.h> RC100 Controller ; Controller . begin ( 2 ); //RC100 init equally IR manner The remaining deportment are the same as the previous example.
BKP Library
The BKP Retentivity ever preserves the data as long as the power is kept on so it is useful for temporarily saving user data or important information and and then, after returning from reset, accessing the data over again. The OpenCM board provides API for the BKP Memory as an external library. Select File -> Examples -> BKP -> ReadWrite every bit shown below.
One time you lot select the examples the post-obit codes announced.
Example Explanation
In setup() we initialize the BKP Memory and initialize the Serial2 device to 57,600bps. Then print "Get-go OpenCM9.04 BKP Memory Examination" through Serial2 and start loop().
STM32F103CB of OpenCM is composed of a BKP Memory with a total of ten 16bit registers.
In loop() we will output data from addresses 1 to x with a 1 second interval, and when
#include "BKP.h" BKP BKP_MEMORY ; int i ; void setup (){ /* Initialize clock and registers for BKP*/ BKP_MEMORY . begin (); Serial2 . begin ( 57600 ); Serial2 . println ( "Start OpenCM9.04 BKP Memory Test" ); } void loop (){ delay ( 1000 ); for ( i = 1 ; i < eleven ; i ++ ){ Serial2 . print ( "BKP Retention Read = " ); Serial2 . println ( BKP_MEMORY . read ( i )); } if ( Serial2 . bachelor ()){ BKP_MEMORY . enable (); for ( i = 1 ; i < 11 ; i ++ ){ BKP_MEMORY . write ( i , i * x ); } BKP_MEMORY . disable (); } } An of import property of the BKP Retentivity is that even if you lot press Reset and the CPU restarts, the BKP Memory values will remain the same. Nonetheless if y'all unplug the power and then plug in the power again the data will disappear. Below you lot can check the property of the BKP Retentivity using the output value.
Open Led Software Download for Mac
Posted by: dorothyonews1951.blogspot.com
Post a Comment