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.

TIP 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

  1. Make a folder for the new node under C:\rise_mcu\nodes
  2. Copy F33x-rb.c from C:\rise_mcu\lib to the new folder
  3. Rename the local copy of F33x-rb.c to app.c
  4. Open a new project in SiLabs?
  5. Right-click on New_Project and add app.c
  6. Save the project in the new folder.
  7. Open Project>>Tool Chain Integration
  8. 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
  9. Goto Project>>Target Build Configuration.
    • Make sure the "Absolute OMF file name has a .OMF extension" otherwise the project will not build correctly.
  10. 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)
  11. Choose a RiSEBus? and I2C? address for the node.
    • Each I2C? must be unique within a particular RiSEBus? .
    • Save the RiSEBus? info to config.hh
    • Save the I2C? address in app.c as a constant in the form:
         #define NODE_RB_ADDRESS    0x01
         
  12. At this time, we are only creating one node, thus our index value defaults to zero.
       #define NODE_INDEX         0x00
       
  13. At this time, we'll use only one outgoing mailbox. So, we delete the inbox constants.
  14. We are sending two bytes, so we change OUTBOX1_SIZE to 2
  15. Add rbclass.h to the include files
       #include <rbclass.h>
       
  16. Make constants for the version and revision, set them both to 1
    • Note: Version is a 6-bit number (limited to a range of 0-63). Revision is a 2-bit number (limited to a range of 0-3)
         #define  NODE_VERSION       1
         #define  NODE_REVISION      1
         
  17. Using the defined constants, modify the function call arguments in app_init() and delete the extra rbmb_confOutbox()
  18. 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
  19. Seperate your code into three parts: initialization, background process (things that constantly run) and sensor reading code.
  20. Add a call to your initialization inside of app_init() and a call to your background process inside of app_idle()
  21. 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( );   
       
  22. 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

  • Connect the node to the I2C? bus on RiSE
  • Use the CarrierList program availible in ~/RoboDevel/RiSE/RobotCode/TestTools/CarrierList
  • To program the micro, you must
    1. Start CarrierList on RiSE to power the node.
    2. Connect to the micro (Alt+C in SiLabs? )
    3. Download the code (Alt+D in SiLabs? )
    4. Disconnect from the micro (Alt+C in SiLabs? )
    5. Restart CarrierList on RiSE
  • The node should appear in one of the tables as follows
    ==================================
    Bus Configuration for RiSEBus(3)
    ==================================
     addr | class | index | version | dep |
     0x00 | Broadcast address             |
     0x01 |   5   |   0   |   1/0   |  n  |
     0x02 |   5   |   1   |   1/0   |  n  |
     0x03 |   5   |   2   |   1/0   |  n  |
       
    • This table shows three different nodes of class 5 (which is the LSANs) connected to RiSEBus? 3

Develop Linux/QNX code

  1. 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.)

 
This site is powered by the TWiki collaboration platformCopyright &© by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback