A project log for 3D Printed Robot Actuator

A high speed and high torque robotic actuator using low-cost brushless motors, custom controller, 3D printed parts and bearings.

Paul GouldPaul Gould 10/13/2018 at 15:230 Comments

The PSOC4 and the IDE Creator helps you to write code for the Arm processor, the CAN peripheral and the FPGA logic. When you use it for standard operations, then you rarely need to go deep into the component datasheets to make the design work as required. The examples are quite useful.

But, if you want to design something that is not normal, then it is hard to find the information required.

CAN Problem 

Each Actuator needs to have it's own individual address or CAN IDs. In my robot there will be at least 12 actuator controllers that will be CAN slaves, with one controller configured as a CAN master.  This requires setting the CAN Receiver Mailbox ID via software. It is normally done in the .cysch CAN configuration page.

There is a easy for setting the Transmit message ID.


There was no such sub-routine for the setting the RX message ID. So after a lot of reverse engineering and some trial and error, the following code is used. Set different IDs for each actuator. 

CY_SET_REG32((reg32 *) (CYREG_CAN0_CAN_RX0_ACR), (0x0200000u*ID));

This only works for Message Mailbox 0 and is good for my current needs. A second mailbox maybe required in the future that will be a broadcast message so all the receiver message Mailbox IDs will be the same. This could be used for an Emergency stop message. Send one message and all the actuators stop.

Additional CAN information

If the RTR in the Configure 'CAN' is enabled, the CAN transmitter will re-transmit the current packet until the received sends an Acknowledge packet back. 

FLASH Problem

As each Actuator needs to have it's own individual ID, this value and some others needed to be stored in flash memory. But when the PSOC4 software is updated it erases ALL of the standard FLASH. It also does not have EEPROM. It has an emulated EEPROM but again this is erased after updating the program. The PSOC4 I'm using has user FLASH but there is no information on how to use it. 

The set-up code is

#include <CyFlash.h>

uint8 Flash_User_Array[CY_SFLASH_SIZEOF_USERROW];

To Read from FLASH, I set up a RAM array the same size as a FLASH row.

    uint16 i;
    for (i = 0u; i < CY_SFLASH_SIZEOF_USERROW; i++)
        /* Define source value */
        Flash_User_Array[i] = (*((uint8 *) (CY_TEST_USER_FLASH_ADDR + i)));

 To Write to FLASH, I set up a RAM array the same size as a FLASH row.

    cystatus returnValue = CYRET_SUCCESS;
    returnValue = CySysSFlashWriteUserRow(CY_TEST_USER_FLASH_ROW, Flash_User_Array);