ElectricMotorcycleForum.com

Makes And Models => Zero Motorcycles Forum | 2013+ => Topic started by: togo on August 28, 2019, 01:15:55 AM

Title: controlling TC-charger with Raspberry Pi Zero W and Waveshare RS485 CAN Hat
Post by: togo on August 28, 2019, 01:15:55 AM
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
Title: Re: controlling TC-charger with Raspberry Pi Zero W and Waveshare RS485 CAN Hat
Post by: Shadow on August 29, 2019, 05:37:32 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!
Title: Re: controlling TC-charger with Raspberry Pi Zero W and Waveshare RS485 CAN Hat
Post by: togo 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%.