I am trying communicate via CAN using a UC5550 on a UCM DEV board (rev. E) but have been unsuccessful. I am new to TinyCLR and embedded development, in general. I got the bootloader, firmware and sample programs loaded successfully. Have there been any others that have been successful in CAN communication with this hardware? I have wired the UCM board from CAN A port to a USB to CAN converter in my PC that I have verified is working correctly. I have tried sending command from PC to UCM but I get no response on the Visual Studio console window.
I am using the code in the website tutorials sections, CAN sub-section. I have modified the code below based on different hardware than the example code. Is there anything obvious I am doing wrong?
var downButton = GpioController.GetDefault().OpenPin(0);
downButton.SetDriveMode(GpioPinDriveMode.InputPullUp);
var can = CanController.FromId(UC5550.CanBus.Can1);
How do I determine the openPin # for the hardware I have if I want to put GPIO PinC on the dev board low?
Do I need I need to jumper the CAN termination?
Is there any other detailed TinyCLR API documentation for CAN other than the tutorial?
Lastly, now Windows is not recognizing my UC5550 board via USB. Not sure if something bad has happened. Any ideas on recovery?
Sorry for all the questions. Thanks for your help.
For now, ignore the hardware not functioning issue. That is something that happened long after I was not able to get any CAN communication working.
My main focus is getting CAN communication working. The example online code is for a G120E and I am using a UC5550 with UCM dev board. What are your recommendations, code-wise, for CAN communication testing. How do I determine the openPin # for the hardware I have if I want to put GPIO PinC on the dev board low?
There is no “open pin” for CAN. Please see this CAN
We use a button in the demo and that is the GPIO but beside that CAN does not need GPIO.
I would say start with a simple example that sends a CAN message once every second. Then check for that message on your other device. Do not forget to have a termination resistor on your wires.
I would like to use the same concept as in the demo where one puts a digital input low to send a can message (rather than send every x seconds). I am using the UCM dev board and would like to use GPIO C. So my question is basically more around pin mapping. For the code below, what is the correct pin Id # for GPIO C that I would use? Documentation on the UCM and UC5550 is unclear.
var downButton = GpioController.GetDefault().OpenPin(0);
Regarding the pin question, you’ll want to use the GHIElectronics.TinyCLR.Pins.UCM library. You’ll then call GHIElectronics.TinyCLR.Pins.UCMStandard.SetModel(…) at the start of your program. After that, you can pass GHIElectronics.TinyCLR.Pins.UCMStandard.GpioPin.C to OpenPin.
No expert but I think this is what you want.
The Developer board LED by the IRQ A button
Using a UC5550
Review the schematic for the UC5550. It shows the pin ID for every pin
GPIO C LED
The signal will be seen on Header B - Pin GPIO C
int time_ms = 1000;
GpioPin led_GPIOC = GpioController.GetDefault.OpenPin(UC5550.GpioPin.PG3);
led_GPIOC.SetDriveMode(GpioPinDriveMode.Output);
// Blink GPIO C LED by the IRQ A button
for (int i = 1; i <= 4; i++)
{
Debug.WriteLine("TinyCLRApplication test " + i.ToString());
led_GPIOC.Write(GpioPinValue.High);
Thread.Sleep(time_ms);
led_GPIOC.Write(GpioPinValue.Low);
Thread.Sleep(time_ms);
}
Any recommendations for the CAN timing parameters for the UC5550 (see list below)? I am getting the following text on the console output : Error GHIElectronics.TinyCLR.Devices.Can.ErrorReceivedEventArgs when I try to send. I have tried different CAN timing parameters and looked at various web calculators but have been unsuccessful. I will be communicating with a device that is set to 125 kbits/sec. Thanks for any input.
var propagation = 0;
var phase1 = 7;
var phase2 = 4;
var baudratePrescaler = 20;
var synchronizationJumpWidth = 1;
var useMultiBitSampling = true;