Modbus send help for communicating with controller

Electric Motors and Controllers
Post Reply
ProEV   100 mW

100 mW
Posts: 47
Joined: Aug 22 2013 9:56am

Modbus help with Grin Technology BAC2000 controller

Post by ProEV » Nov 19 2016 10:32am

Hi,

I need some help from people with greater knowledge of Modbus. I have had sucess reading data from the controller using function 3, READING HOLDING REGISTRIES but have not been able to write to the controller using function 6, SET SINGLE REGISTRY. When I try and write a value, I get back 'exceptional error'.

I send:
01 03 00 9B 00 01 F5 E5
And get back
01 03 02 08 00 BF 84
Which tells me that the parameter 155 Battery Current limit is 0800 so 2048 which divided by the scale 40.96 gives me 50% which agrees with what the manufacture supplied BACDoor software tells me.

I try and write a new value such as 100% which is 4096 so 1000.
I send
01 06 00 9B 10 00 F5 E5
I get back
01 86 01 83 A0
Which is an exceptional response with 01 being an illegal function.

The documentation http://www.accelerated-systems.com/KB/?p=552 says that I should be able to read and write this parameter. The BACDoor software permits me to modify the parameter.

Why does directly sending the command not work? Does the BACDoor software go 'Simon says' before sending a 'write' command?

Background:

The BAC 2000 controller http://www.ebikes.ca/shop/electric-bicy ... c2000.html from Grin Technologies is very flexible and seems to be doing everything I want well. I am running it sensorless with an Astro 3220 motor. It is an FOC controller and cousin to Grin Technologies excellent Phaserunner controllers.

Both controllers use Modbus over a simple serial connection to communicate. I am trying to leveraging that ability to set up an Arduino board to read information and adjust the controller on the fly. Grin Technologies already offers the CA3 http://www.ebikes.ca/product-info/cycle-analyst-3.html which will satisfy most people's needs but for electrathon racing, I need more control.

Any suggestion?

ProEV   100 mW

100 mW
Posts: 47
Joined: Aug 22 2013 9:56am

Modbus send help for communicating with controller

Post by ProEV » Nov 29 2016 1:36pm

Hi,

I posted this on the Bike Technical forum section a few days ago but had no luck, so I thought I would try here.

I need some help from people with greater knowledge of Modbus. I have had sucess reading data from the controller using function 3, READING HOLDING REGISTRIES but have not been able to write to the controller using function 6, SET SINGLE REGISTRY. When I try and write a value, I get back 'exceptional error'.

I send:
01 03 00 9B 00 01 F5 E5
And get back
01 03 02 08 00 BF 84
Which tells me that the parameter 155 Battery Current limit is 0800 so 2048 which divided by the scale 40.96 gives me 50% which agrees with what the manufacture supplied BACDoor software tells me.

I try and write a new value such as 100% which is 4096 so 1000.
I send
01 06 00 9B 10 00 F5 E5
I get back
01 86 01 83 A0
Which is an exceptional response with 01 being an illegal function.

The documentation http://www.accelerated-systems.com/KB/?p=552 says that I should be able to read and write this parameter. The BACDoor software permits me to modify the parameter.

Why does directly sending the command not work? Is there normally some other command that tells the controller this is from 'official' software?

Background:

The BAC 2000 controller http://www.ebikes.ca/shop/electric-bicy ... c2000.html from Grin Technologies is very flexible and seems to be doing everything I want well. I am running it sensorless with an Astro 3220 motor. It is an FOC controller and cousin to Grin Technologies excellent Phaserunner controllers.

Both controllers use Modbus over a simple serial connection to communicate. I am trying to leveraging that ability to set up an Arduino board to read information and adjust the controller on the fly. Grin Technologies already offers the CA3 http://www.ebikes.ca/product-info/cycle-analyst-3.html which will satisfy most people's needs but for electrathon racing, I need more control.

Any suggestion?
ProEV

User avatar
cycborg   1 kW

1 kW
Posts: 468
Joined: Jul 05 2014 4:45pm
Location: Boston metro, US

Re: Modbus send help for communicating with controller

Post by cycborg » Dec 02 2016 4:15pm

If you can change parameters with BacDoor, I'd suggest running a serial port monitor program to see what it's sending that you're not.

ProEV   100 mW

100 mW
Posts: 47
Joined: Aug 22 2013 9:56am

Re: Modbus send help for communicating with controller

Post by ProEV » Dec 03 2016 4:07pm

cycborg wrote:If you can change parameters with BacDoor, I'd suggest running a serial port monitor program to see what it's sending that you're not.
Excellent idea but one I was hoping someone else had already done.

What I discovered is BACDOOR is using the Function 16 Set Mutiple Registries and just writing to one registry. I was using a demo version of Simply Modbus http://www.simplymodbus.ca/index.html which is great to understand exactly what to send but when you try and write to just one registry, it forces you to use Function 6.

So since Function 6 does not seem to work, the same thing can be done with function 16.

So instead of

01 06 00 9B 10 00 F5 E5

I send this

01 10 00 9B 00 01 02 10 00 B7 BB

It works like a charm and I can now control the controller with the Arduino.

User avatar
cycborg   1 kW

1 kW
Posts: 468
Joined: Jul 05 2014 4:45pm
Location: Boston metro, US

Re: Modbus send help for communicating with controller

Post by cycborg » Dec 05 2016 12:52pm

Good news. Are you only able to change static parameters (limits, etc.), or can you do dynamic control (i.e. throttle setting) as well?

ProEV   100 mW

100 mW
Posts: 47
Joined: Aug 22 2013 9:56am

Re: Modbus send help for communicating with controller

Post by ProEV » Dec 06 2016 3:01pm

I am planning on using 'battery current limit' to do throttle mapping. The Arduino reads RPM and then calculates the most efficient current for that RPM. It then sends to the controller a new 'battery current limit' that limits full throttle to the most efficient current. The driver just drives the car as hard as possible without having to baby the throttle. This should happen around ever .2 of a second, so fairly dynamic :D .

There is also a 'Passing' button that resets to 100% when full power is called for.

What I like about this approach is I am not messing with the actual throttle signal in case the Arduino crashes during a race.

The manual says throttle can be set by a serial signal, so I suspect actually controlling the throttle signal should be doable.

pm_dawn   100 W

100 W
Posts: 164
Joined: Jan 17 2009 3:36pm
Location: Östersund, Sweden

Re: Modbus send help for communicating with controller

Post by pm_dawn » Dec 13 2016 6:38am

I have been usind the simple program "Modpoll" when testing MODBUS stuff.
It can send both for serial and tcp/ip.

Can be useful.

Regards
/Per

Post Reply