Author Topic: (SOLVED) Issues Controlling VEC200 with Separate (Raspberry Pi) Microcontroller  (Read 9956 times)

Offline MattGeo

  • Confirmed
  • New Member
  • *
  • Posts: 4
I am trying to use the GPIO pins on my Raspberry Pi to send a voltage signal to the throttle signal wire on the VEC200 controller to drive the HPM3000 BLDC motor. I know the setup works because I was able to get the motor to spin on its own by connecting the throttle to the Pi in some weird way. After playing around with some things, I now get no response from the motor and 12 LED blinks indicating the "Throttle input is abnormal" which is not very helpful. I tried connecting the throttle signal wire to a 3.3V output, as well as a 5V output (not at the same time), expecting the motor to run constant at maximum throttle. I understand that there may be a safety feature which stops the motor if the throttle signal is not initialized to be ~0.8-1V, so I wrote a program to allow me to change the pin output from LOW to HIGH (~1V to ~3.3V), expecting the throttle to turn off and on. I also tried using PWM to send 25% duty cycle (~0.8V) and then 100% duty cycle (3.3V) to the throttle signal wire. I adjusted throttle voltage inputs in the VEC200 controller programming software, but I still get the 12 LED blinks and no throttle activation.

SOLVED!!! PWM signal is required to communicate with the signal pin on the VEC200 motor driving controller. It turns out the pwm functions I was using from the bcm2835 gpio library for the Raspberry Pi were not working. I even used the example pwm.c script from the bcm2835 github page and it was not writing any signals. I used the wiringPi library available for the Raspberry Pi to write the pwm signal to the throttle signal wire. My script was set up like a push button script. If the button wasn't being pressed, 0.25% duty cycle pwm signal (~0.8V) was written to the throttle signal wire so that the VEC would recognize the signal as a proper hall throttle (even though it is just a Raspberry Pi, the motor would do nothing at this point); if the button was being pressed, 100% duty cycle pwm signal (~3.3V) which started spinning the motor. This gave me momentary control for as long as the script was running. As far as the two other wires on the throttle harness (5V red and Ground black), the ground wire should be connected to the Raspberry Pi's ground, to complete its circuit for the throttle signal wire to receive voltage from the Raspberry Pi; because the Raspberry Pi can have its own power supply, the 5V wire is not needed for now, but should have its connection covered, since the ground wire is connected to the Pi, you don't want any accidental connections.
Notes: The nominal pwm clock rate for the wiringPi library (100 MHz I believe) seemed to work fine for this application.

I noticed there are not a ton of examples found online of others controlling their motor drivers, specifically for motors of this scale, with separate open-source programmable microcontrollers as opposed to traditional e-bike throttles and breaks and such. This thread could be helpful for anyone who is trying to automate their application of electric motors or, like in my case, trying to control their motor from 1000m away!. Has anyone tried using microcontroller GPIO pins to communicate with electric motor drivers (VEC) and found success? If so, please reply to this post.
« Last Edit: April 03, 2020, 10:56:59 AM by MattGeo »

Offline Bikemad

  • Global Moderator
  • Professor
  • PhD. Magic
  • ******
  • Posts: 5,553
Re: Issues Controlling VEC200 with Raspberry Pi microcontroller
« Reply #1 on: April 01, 2020, 10:10:59 PM »
Hi Matt andto the forum.

After playing around with some things, I now get no response from the motor and 12 LED blinks indicating the "Throttle input is abnormal" which is not very helpful.

I would be very helpful to know what you may have altered that could have caused this problem.  ;)

If you have changed the Throttle mode selection from "1:Linear" to "0:Hyperbola", the controller would now need to be powered up with the throttle in the mid position ~2.5V to avoid the 12 blink error.
The "Hyperbola" mode is only used for boat type throttles with a centre Neutral position and forward and reverse speeds are controlled by moving the throttle lever either forward or backwards from the default neutral position:



I suggest that you use a proper throttle (or a 10k Ohm potentiometer) to verify that the controller and motor both work properly within the expected throttle signal voltage range (0.8~4.0V).

I presume that the Pi and the controller both share the same common negative ground connection.  ::)

Have you used a voltmeter to see exactly what the throttle signal voltage is when the 12 blink error occurs?

A capacitor placed between the throttle signal and ground wires might smooth out the signal voltage from the Pi and damp out any erroneous high or low voltage pulses that could be causing the 12 blink error.  :-\

If the error is being caused by a low throttle signal voltage, it should be possible to use a 5K multi turn trim potentiometer, a 4.7K resistor and diode to set the required voltage and prevent it from being too low when the controller is initially powered up:


You would simply wire it up as per the lower left corner of the above diagram.  ;)

Alan
 

Offline MattGeo

  • Confirmed
  • New Member
  • *
  • Posts: 4
Thanks for the help! Could you please explain to me how exactly the brake works on the VEC200 controller? I believe there is only a black ground wire and a blue 5V supply wire.

Offline Bikemad

  • Global Moderator
  • Professor
  • PhD. Magic
  • ******
  • Posts: 5,553
The most common way of operating the brakes is to use a separate brake switch to activate the regenerative braking function.

The switch would have the Blue/White brake signal wire (+5V on the diagram below) on one contact, and the Black ground wire (GND) on the other brake switch contact:



Closing the contacts by activating the brake switch will cause the regenerative braking to operate.

If you are installing the motor into a vehicle which already has its own 12V brake light system, you can connect the switched +12V output from the vehicles brake light switch to the Yellow/White +12V Brake signal input wire to operate the braking function.

You should only be using one of the two available "brake" or "high brake" wires, not both of them. ;)

Unfortunately, the regenerative braking is not variable, as it only toggles between Off and On even if a potentiometer is used to trigger the braking function instead of an On/Off switch.

I don't think you will be able to smoothly control the level of braking using a PWM signal on the brake wire due to the delayed braking response, which will probably result in intermittent but very jerky braking. However, if you would like to try it out, it would be useful to know whether my suspicions are right or wrong. ;)

I don't know whether the brake wire cuts the power to the motor on the VEC controllers like it does on the internal GM vector controllers, but operating the brake switch should disengage the cruise control if it was active prior to the brakes being applied.

Good to see that you've finally got the motor/controller working with the Raspberry Pi.  ;)

Alan
 
« Last Edit: April 03, 2020, 04:28:15 PM by Bikemad »

Offline MattGeo

  • Confirmed
  • New Member
  • *
  • Posts: 4
Thanks for the clarification. So when the brake is engaged, the motor will stop? It being regenerative, does that mean it will try to charge my batteries while it is braking?

Offline Bikemad

  • Global Moderator
  • Professor
  • PhD. Magic
  • ******
  • Posts: 5,553
If the motor is attached to a vehicle and the regen (ebrake) is activated while travelling at high speed, then it could noticeably charge the battery.

However, if the motor is only used to drive an air conditioning compressor or a water pump etc., applying the ebrake would simply stop the motor very quickly, which might (just for a split second) produce a tiny amount of charge dependant upon the initial rpm and the combined inertia forces present in all of the moving components. :-\

Alan
 

Offline MattGeo

  • Confirmed
  • New Member
  • *
  • Posts: 4
Do you think the regen could potentially damage the batteries by providing charge current that is too high or an unbalanced charge? (I am using multi-cell LiPo batteries which are normally balance charged at no more than 14A)

Offline Bikemad

  • Global Moderator
  • Professor
  • PhD. Magic
  • ******
  • Posts: 5,553
If you live at the top of a long steep hill you could potentially start your trip with a lot of high speed braking on a fully charged LiPo pack, which could be a problem for the LiPo pack if the controller doesn't protect it.

If this is the case, try not to fully charge the pack before use to ensure there is sufficient storage capacity for the regen power your motor is likely to produce.

I don't know how high the regen current from your particular setup could be, but you should be able to set the maximum level of regen charging current and the maximum charging voltage in the software, or alternatively, you could simply disable the EBS altogether.

Alan