ElectricMotorcycleForum.com

  • November 26, 2024, 03:55:49 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Electric Motorcycle Forum is live!

Pages: [1]

Author Topic: controlling TC-charger with Raspberry Pi Zero W and Waveshare RS485 CAN Hat  (Read 717 times)

togo

  • It's like flying. But with more traction.
  • Hero Member
  • *****
  • Posts: 1639
    • View Profile

Using lennart's arduino code as a guide, I successfully controlled a pair of the 3.3kw elcon/TC chargers to charge my 2014 Zero SR a couple of times.

Very rough code:

https://drive.google.com/open?id=1R3gS66uGDV9o_wc7Ud1f6OeaU8uCLZRi

Pictures of the unit:

https://photos.app.goo.gl/kcDiV1kAhGinndR38

i2c Touch Hat is also from waveshare, and their example "python" code doesn't work right (throws a too many open files exception after a few minutes, and it's got an ugly binary blob anyway) so I adapted some generic i2c and read the touch with pure python instead.

Since it doesn't have a display yet, I start the code and control the charge level by connecting to the Pi Zero W with a laptop.

I intend to add a display and then clean up the code and then publish on github, but if anyone else wants to try it, I'd be happy to collaborate.

Tony
Logged
our knowledge about Zeros collects here: https://zeromanual.com/

Shadow

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1085
  • 130,000mi electric since 2016
    • View Profile

Nice proof of concept!
Of course the systems programmer in me is giving floating point maths and avoidance of bitwise shift operations a curious glance... more importantly if it works, then it works!
Logged

togo

  • It's like flying. But with more traction.
  • Hero Member
  • *****
  • Posts: 1639
    • View Profile
Re: controlling TC-charger with Raspberry Pi Zero W and Waveshare RS485 CAN Hat
« Reply #2 on: September 03, 2019, 01:37:56 AM »

Nice proof of concept!
Of course the systems programmer in me is giving floating point maths and avoidance of bitwise shift operations a curious glance... more importantly if it works, then it works!

Thanks.

Yeah, the 10x encoding of the TC canbus means you have to deal with 0.1 numbers.  Fixed point could be done in Python, I guess.  Mostly I was trying to make sure I was isolated from any endian-ness, didn't want to have it behave differently on Armbian vs x86_64/i686.

Next I'll probably swap out the touch input for touchscreen and add monitoring and control of Wemo Insight for the times when I want to do onboard charging and stop below 100%.

Logged
our knowledge about Zeros collects here: https://zeromanual.com/
Pages: [1]