B&R PLC configuration: 4ms task with X20CP1381 CPU + ACOPOSmicro + X20SM1436

I recently used a hardware configuration where a B&R X20CP1381 CPU was controlling a couple of async motors using the ACOPOSmicro and a stepper motor using the X20SM1436. I needed a task running at 4ms but the current configuration was set to 10ms. When you add an ACOPOS controller, the CPU system timer configuration changes automatically to EPL/X2X Interface and the POWERLINK interface is selected, in my case it is the IF3 interface. The POWERLINK cycle time is 10ms by default in a new project.

So, in order to change my tasks cycle time, I have to change the POWERLINK cycle time to 4ms, which allows me to set the #1 Task classes timing to 4ms.

All looked fine, I tested the async motors and they were working, but when I tested the stepper motor I had an error, don’t remember its code but it was something related to timing. I opened the X2X (IF6) bus configuration and changed its cycle time also to 4ms. This fixed the problem! I think the reason is that the ncsdcctrl program is in the cyclic #1 tasks group running at 4ms and the X2X bus was running slower. I guess that if I had placed the ncsdcctrl program in a 10ms task it would also fix the issue, as the X2X cycle time is 10ms by default. Ho well, 10 is not a multiple of 4 so I can’t have a 10ms task, that fix wouldn’t work ;-) So probably the only possible solution is to have the POWERLINK, the X2X bus and the ncsdcctrl program all running at 4ms.

LIDAR lite with Beaglebone Black and Arch Linux

Its been a few months now since I received my new LIDAR lite from the crowd funded campaign on Dragon Innovation but only now I have some time to play with it. I got interested in range finder hardware after doing this great Udacity course on Artificial Intelligence for Robotics by Sebastian Thrun (the new one is here). One of the key hardware components is a good inexpensive range finder and Pulsedlight is doing it.

I want to try it out on my Beaglebone Black, the first challenge are the data pins voltage, the LIDAR is working at 5V and the Beaglebone at 3V3.

(EDIT) Well, figures out that I was wrong about LIDAR lite I2C levels, even thought it works with the logic levels converter, it is not necessary to use it, check my new post here.

I have hanging around a 4-channel I2C-safe Bi-directional Logic Level Converter – BSS138 from Adafruit. It is perfect for this. Here are some photos of the connections, I’ll publish the wiring in a few days when I have more time:

lidarlitewiringConnection to the Beaglebone via ssh.
The Beaglebone is running Arch Linux, to install the i2c tools:

# pacman -S i2c-tools

Check if the LIDAR is there:

# i2cdetect -r -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- UU UU UU UU -- -- -- -- -- -- -- --
60: -- -- 62 -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Looking good! LIDAR Light detected at address 0x62.  Now, from its manual, we need to write 0x04 at its address 0x00 to make a measurement:

# i2cset -y 1 0x62 0x00 0x04

and wait for a couple of seconds to make sure the measuring is finished, then read the measured value:

# i2cget -y 1 0x62 0x8f w

so I’m getting 117cm. It works! And the distance from it to my wall is around that value. Can’t find my meter so I can’t check its precision right now. I made a simple script to make it run for a while and save the measuring in a file, I’ll let you know my findings about repeatability later. Here is the script:

date >> lidar.txt

while :
i2cset -y 1 0x62 0x00 0x04

sleep 2

i2cget -y 1 0x62 0x8f w
i2cget -y 1 0x62 0x8f w >> lidar.txt

I couldn’t use the i2cdump command. Each time I do:

# i2cdump -y 1 0x62

I get an answer the first time with some values but if I do the i2cdump again the result is all zeros, it looks like something gets stuck and the LIDAR no longer responds. The only way to make it work again is to power down / up the LIDAR. I’ll investigate this another day.