Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get two controllers (intelligent and motion) to communicate with each other #2

Open
console-beaver opened this issue Dec 13, 2019 · 28 comments

Comments

@console-beaver
Copy link

We are trying to use your code (thanks alot for publishing it), but cannot get both controllers to negotiate. So intelligent controller keep sending CAN Bus packets to motion controller and motion controller's light stays red and never turned to blue.

Can you explain which CAN interface need to be connected to each controller? I.e. is it can1 connected to intelligent controller and can2 - to motion controller? Is it opposite? Thanks!

@console-beaver
Copy link
Author

Tried to switch can buses around, i.e. can 1 goes to motion controller and can2 - to intelligent controller, but no worky.

Curious if anyone else besides the author got it working using this code?

@console-beaver
Copy link
Author

Which S1 firmware you did test this code against?
Apparently, it doesn't work on our S1 which is running very old (original) firmware release...

@JohnieBraaf
Copy link

Yes, I can confirm it is working. I suspect that you're can bus timing is off. Make sure you clock it at 1Mbit.

@console-beaver
Copy link
Author

Oh sorry, that was the very old question. I got it working too awhile ago.

@krvcz
Copy link

krvcz commented Nov 11, 2020

Oh sorry, that was the very old question. I got it working too awhile ago.

Hi, how exactly did you solve the problem? Where should I set Can to 1 Mbit?

@console-beaver
Copy link
Author

@krvcz my issue was related to CAN bus physical connection and not the baud rate, and could be different from your issue. Basically, I was trying to connect it to both intelligent controller and motion controller at the same time with both CAN1 and CAN2 interfaces. Now with the new code, the intelligent controller was eliminated completely, and you have to use CAN1 interface only (by default, unless you change the code to use CAN2 instead).

@krvcz
Copy link

krvcz commented Nov 11, 2020

@krvcz my issue was related to CAN bus physical connection and not the baud rate, and could be different from your issue. Basically, I was trying to connect it to both intelligent controller and motion controller at the same time with both CAN1 and CAN2 interfaces. Now with the new code, the intelligent controller was eliminated completely, and you have to use CAN1 interface only (by default, unless you change the code to use CAN2 instead).

Thank you for reply. We stack with this project, so do you have any photos with connectivity ? Can we chat somewhere , for example gmail or Facebook etc.

Now i can’t download project, with error „no such or directory in lwip/otp.h „

@JohnieBraaf
Copy link

20201111_222138

You only need 1 CAN bus is the latest version of the software. Still had it laying around so see pic.
In his previous version he indeed programmed it as a passthrough device. Not anymore.
It has been couple of month ago and I have not checked after that.

I also wrote a micropython version but it's not yet finished, it spins the wheels though. Let me know if interested.

@JohnieBraaf
Copy link

JohnieBraaf commented Nov 11, 2020

For wiring:

  • Unplug the main unit, the one with the antennas
  • connect Gimbal CAN bus (High, Low) wires to the CAN tranciever. No need to add ground
  • power microcontroller and tranciever with 5V

Thats it.

PS. I also removed the termination resistor, not sure if needed, but I was also capturing the signal on the other microcontroller running micropython.

@krvcz
Copy link

krvcz commented Nov 11, 2020

For wiring:

  • Unplug the main unit, the one with the antennas
  • connect Gimbal CAN bus (High, Low) wires to the CAN tranciever. No need to add ground
  • power microcontroller and tranciever with 5V

Thats it.

PS. I also removed the termination resistor, not sure if needed, but I was also capturing the signal on the other microcontroller running micropython.

Thanks a lot ! Soon as possible i will inform you about progress or possible errors . Is there a version with 2 Can buses in the picture?

@JohnieBraaf
Copy link

JohnieBraaf commented Nov 12, 2020

Edit: yes, not sure why, but only 1 is actually communicating. Its the purple and grey wires. I think it is the 2 on the right.
Btw, to solve your error, you probably need to download or enable the middleware LWIP in STM-Cube IDE.

@krvcz
Copy link

krvcz commented Nov 12, 2020

Edit: yes, not sure why, but only 1 is actually communicating. Its the purple and grey wires. I think it is the 2 on the right.
Btw, to solve your error, you probably need to download or enable the middleware LWIP in STM-Cube IDE.

Ok, so before I have connected board with 2 CAN's, so now should i download older program with 2 CAN in code, right ?
if it will not working with 2 CAN i'm going to try with only one CAN

@JohnieBraaf
Copy link

You can have a look at my micropython implementation. It's probably much easier to understand. It's working but not finished.

Micropython-S1.zip

@JohnieBraaf
Copy link

"Ok, so before I have connected board with 2 CAN's, so now should i download older program with 2 CAN in code, right ?
if it will not working with 2 CAN i'm going to try with only one CAN"

That version of the code has far less features. And it's actually great to not have to power the main unit. saves battery, so I would say better to have only 1 can.

Also in Micropython I first had a passthrough desing but I was running into performance limitations.

@krvcz
Copy link

krvcz commented Nov 12, 2020

Unfortunately, at the moment I am limited to STM32. I will keep you posted on the progress.
Does your version of micropython use a Rasberry microcontroller?
I would like to have an alternative solution in case of stm problem.

@JohnieBraaf
Copy link

You can run micropython on STM32 boards, see: https://github.com/micropython/micropython/tree/master/ports/stm32/boards
You do need to compile a patched version, see my comments: micropython/micropython#5508

It should also be easy to port to raspberry pi, but then you will need a USB can bus device, or a CAN BUS shield.

@krvcz
Copy link

krvcz commented Nov 12, 2020

One more question: What should be the boot order with ROS and does the boot order matter?
I am talking about version with STM

@JohnieBraaf
Copy link

I don't know, I was not using ROS. Also, there is no ROS in the firmware you are looking at.
The author is using his PC as a bridge and pushes UDP packages to his PC.
You do have this as an option: http://wiki.ros.org/rosserial

@krvcz
Copy link

krvcz commented Nov 12, 2020

hmmm... but in source files are ros files with packages . So the Ros files that are in the source folders are not required?

@JohnieBraaf
Copy link

nope, he is running that on PC running ROS, its not used in the firmware for the STM32

@krvcz
Copy link

krvcz commented Nov 12, 2020

Sorry my bad I have't understood you before. Anyway, If I connect everything (wires + connect with ROS server), then the LED should be blue?

@JohnieBraaf
Copy link

Yes, led blue on control board of Robomaster means it's working. Otherwise it will be red (no controller). Green means lab mode.

@Richard-best86
Copy link

Hi @JohnieBraaf , I saw your comment about micropython version.
It interested me very much. You can tell me how to do it and whether I need to implement ROS?I need some tips.
Please reply.
best regards

@JohnieBraaf
Copy link

JohnieBraaf commented Nov 13, 2020

No I was not using ROS. Basically just use CAN functionality on micropython board. It's very simple.
And I built a class to create CAN messages with CRC and such. It's basically a partial port of this repository.
I meant to use WIFI to send commands, but back then the assyncio was limited, but I had it working at that point.
I believe in the meantime there were big improvements in de micropython project regarding assyncio to swith between CAN sending and WIFI receiving task.

If I find the time I will make a generic working example repository.

@krvcz
Copy link

krvcz commented Nov 13, 2020

Ok, so i was trying connect everything, but still i see red LED :( For test i am using connection by ethernet . I don’t have any ideas to resolve problem . It’s version with one Can as you see and the newest source files.
7B5F646A-6160-42C2-909A-D87370D8DF74
66EF1E5C-66DF-414C-AF3A-78E52CC3CE9C
98B08EC7-F751-42D1-98E2-E58C29AB69B0
3873F94A-662E-4A28-8FCC-79F9D4EA1F7D

@JohnieBraaf
Copy link

JohnieBraaf commented Nov 13, 2020

Here you see it is working like this. I modified the code when if was studying the firmware to send the wheels forward so I could debug. I don't know about ROS, sorry have not used it.

Check your pins, I think you're wiring is different.

Do note that the moment that you power it on matters. It has something like a startup procedure. Number of initial messages.
So make sure the S1 is already running, then turn on microcontroller.

20201113_203458

@krvcz
Copy link

krvcz commented Nov 13, 2020

Thank you a lot for your reply and help. So, I connect the same like you and everything is fine and now i can see blue LED. The only problem is with ROS . Ros server is working , ping stm work as well but robot doesn’t move. I don’ t know where is the problem.
Could you say more about control by ps4 controller in micropython ? Is it wireless ? How connect ps4 controller? Etc. It’ s very important for me . I am very appreciate your help.

@JohnieBraaf
Copy link

@krvcz , @Richard-best86 , I have placed a working example here: https://github.com/JohnieBraaf/Robomaster-Micropython
Lets continue discussion there if you want. It currently only turns on all leds and provides for blue led on the control board.
I will add some basic commands later. B.t.w., micropython seems to support the ethernet cable as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants