This page currently holds the log of our attempt to create an ultrasound sensor RiSEBus node. We plan to convert the log into a tutorial for creating a generic RiSEBus node.
--
SalomonTrujillo - 18 Jul 20
Develop Standalone Code
Copy the ~/RoboDevel/RiSE/EmbeddedCode directory over to a Windows machine that has the
SiLabs? IDE.
Develop and test your code on the development board
We prefer to use the c8051f330 because of the availability of a DIP packet (for ease in prototyping.) We also prefer using a UART.
I'm not sure why, but occassionally, the code won't link, with the an error about not finding a symbol
?extw
. This can be resolved by copying the file
C:\rise_mcu\lib\runlib3.asm
to your local directory and adding the file to the build.
Create new RiSEBus project
- Make a folder for the new node under C:\rise_mcu\nodes
- Copy F33x-rb.c from C:\rise_mcu\lib to the new folder
- Rename the local copy of F33x-rb.c to app.c
- Open a new project in SiLabs?
- Right-click on New_Project and add app.c
- Save the project in the new folder.
- Open Project>>Tool Chain Integration
- Set Tool Vendor to Dunfield
- Assembler Tab:
- Set Executable to ...\MC\bin\asm51.exe
- Set flags to -f -i -s
- Complier Tab:
- Set Executable to ...\MC\bin\mcc51.exe
- Set flags to -c -l -s m=3
- Linker Tab:
- Set Executable to ...\MC\bin\slink.exe
- Set flags to i=t33xRBOS.lib l=C:\rise_mcu\lib -s
- Processor Tab:
- Command line flags: -c -l l=C:\rise_mcu\inc MCU_FAMILY=330
- Goto Project>>Target Build Configuration.
- Make sure the "Absolute OMF file name has a
.OMF
extension" otherwise the project will not build correctly.
- Choose a unique class id for the node. Update the following files and commit them to CVS
- ~/RoboDevel/RiSE/RobotCode/Hardware/RiSE_RBHW/config.hh
- ~/RoboDevel/RiSE/EmbeddedCode/inc/rbclass.h (Linux version of rbclass.h)
- C:\rise_mcu\inc\rbclass.h (Windows version of rbclass.h)
- Choose a RiSEBus? and I2C? address for the node.
- At this time, we are only creating one node, thus our index value defaults to zero.
#define NODE_INDEX 0x00
- At this time, we'll use only one outgoing mailbox. So, we delete the inbox constants.
- We are sending two bytes, so we change
OUTBOX1_SIZE
to 2
- Add rbclass.h to the include files
#include <rbclass.h>
- Make constants for the version and revision, set them both to
1
- Using the defined constants, modify the function call arguments in
app_init()
and delete the extra rbmb_confOutbox()
- Import your user-code into the project. Make a copy of your .c files. Your user-code should be seperate from the
app.c
code
- Seperate your code into three parts: initialization, background process (things that constantly run) and sensor reading code.
- Add a call to your initialization inside of
app_init()
and a call to your background process inside of app_idle()
- Inside fo
app_sync()
, your code should read the sensor and use rbmbm_setByte to package the data in the outgoing message box.
rbmbm_grabOut1( );
rbmbm_setByte( 0, byte[0] );
rbmbm_setByte( 1, byte[1] );
rbmbm_relOut1( );
- If your result comes as in 16-bit integer, you can use the following code:
unsigned char * byte;
byte = (unsigned char *) &int_var;
- Where int_var is the name of the 16-bit integer you want to send.
- Then use the same
byte[0]
and byte[1]
to access the most and least significant byte.
Test node I2C? bus
Develop Linux/QNX code
- Create a hardware include file with a template for the hardware
- The code is located in
/RoboDevel/RiSE/RobotCode/Hardware/include/hardware
- The best way to start this is with copying a pre-existing template
- Change the class name to a unique describe name.
- This class defines how all implementations (i.e., the physical robot, the simulated robot...) will access the node.
- Modify the
virtual
function calls to reflect the desired function call between the main code and the sensor code (the code will then expect each implementation to provide their own definitions of the calls.)
-