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

Pedal assist support (PAS) #243

Merged
merged 1 commit into from
Dec 9, 2020
Merged

Conversation

nitrousnrg
Copy link
Contributor

This commit enables cadence-based pedal assist for ebikes using
quadrature-style pedal speed sensors.

There are 2 operation modes:

  • PAS only: Motor current is based only on pedal feedback
  • ADC + PAS: The code will use both ADC and pedal feedback and use
    the strongest command to provide seamless overlap when the user is
    pedaling and requests extra torque with the throttle.

For this to work it needs the PAS hall sensor pins configured in the hw_xxx.h,
this is an example:

// Pedal Assist pins
#define HW_PAS1_PORT			GPIOB
#define HW_PAS1_PIN				5
#define HW_PAS2_PORT			GPIOB
#define HW_PAS2_PIN				4

I'm preparing a VESC Tool Pull Request that unlocks the GUI side of this.

This commit enables cadence-based pedal assist for ebikes using
quadrature-style pedal speed sensors.

There are 2 operation modes:
* PAS only: Motor current is based only on pedal feedback
* ADC + PAS: The code will use both ADC and pedal feedback and use
the strongest command to provide seamless overlap when the user is
pedalling and requests extra torque with the throttle.

Signed-off-by: Marcos Chaparro <mchaparro@powerdesigns.ca>
@vedderb vedderb merged commit a17c2f5 into vedderb:dev_fw_5_02 Dec 9, 2020
@vedderb
Copy link
Owner

vedderb commented Dec 9, 2020

Looks good!
I made the PAS pins default to the UART pins if they are undefined. Do you think there is any issue with that?

@nitrousnrg
Copy link
Contributor Author

Glad its merged, I was about to post some datalogs to prove its has been tested.

Looks good!
I made the PAS pins default to the UART pins if they are undefined. Do you think there is any issue with that?

I don't see any real problem with that. One potential problem is that usually a system with PAS most likely will have a display, and most displays use a serial communication so I wonder if people would struggle to have both PAS and display support if PAS takes the UART pins by default. Anyway, I'd say go for it, 2 lines of code are the least of their problems, ebike displays suck because they require some custom and undocumented wiring.

There is another patch coming that provides support to some ebike displays but I'm leaving it for last as it provides very basic support, and will leave it for right before the product goes on sale :)

@Mitchlol
Copy link
Contributor

Sick!

@kylerlaird
Copy link

I'm building ebikes for my family using the Sempu T9 pedal torque BB. It has analog torque and digital cadence outputs. I was planning to just use the torque output to command current (with braking, preferably). I can do this with the standard setup, using the torque sensor as the throttle input, right? This leaves the cadence sensor unused. (When I was still thinking of using an Arduino and another ESC, I considered using cadence for braking. Brake if torque and cadence are both zero.)

Is there any advantage in using PAS mode over standard throttle mode? (Note that I'm new to VESC so I might be missing some basic concepts.)

@nitrousnrg
Copy link
Contributor Author

you might need to use the quadrature sensor (cadence) anyways to make sure the user is not pedaling backwards...

@kylerlaird
Copy link

What would be the issue to resolve if the user pedals backward? The torque will be zero, so it should slow/stop.

@nitrousnrg
Copy link
Contributor Author

What would be the issue to resolve if the user pedals backward? The torque will be zero, so it should slow/stop.

Oh, I've been told that the torque sensor could produce an output when the user was pedaling backwards, but its not necessarily your case

@kylerlaird
Copy link

This one seemed to only register a change while torqued forward when I static tested it. Besides, these bikes freewheel so it's hard for me to imagine getting enough torque to register when backpedaling.

Sidenote...the quadrature signal is handled internally on the T9 and a simple (single) square wave is output for cadence only for pedaling forward. I'm a little disappointed because I was hoping to use backpedaling to activate regen braking (like a coaster brake). Now I'm hoping to regen when torque and cadence are zero - like a very forgiving fixie.

@afzalmam
Copy link
Contributor

afzalmam commented Jan 2, 2021

I am trying to understand the PAS code. In the current code, pas_event_handler() is polled instead of being invoked from ISR. As it is the case, if update_rate_hz is low enough, wouldn't it cause pedal_rpm calculation & thus torque control go wrong ?, sorry if I am wrong, based on code it is what I felt.

Consider the default values for PAS variables,
pedal_rpm_start = 10;
pedal_rpm_end = 120;
update_rate_hz = 500;
magnets = 24;

sleep_time = 2ms (1/500), i.e. thread would get invoked every 2 ms
min_pedal_period = 0.17s [ 1/ ((120/60) * 24 * 3) ]

If both PAS signals are high when pas_event_handler() is invoked, new_state = 3. As both signals can be high during the next invocation of pas_event_handler() (as it would get invoked every 2ms), again new_state = 3.

So per pas_event_handler(),
timestamp - old_timestamp = 2ms;
period = 2ms * 24 = 48ms;
period_filtered = period = 48ms = 0.048s;

Since period_filtered(0.048) < min_pedal_period(0.17), pedal_rpm would not be calculated at this point of time, this case is okay.

Now suppose update_rate_hz = 100, thread would get invoked every 10ms, i.e.,
timestamp - old_timestamp = 10ms;
period = 10ms * 24 = 240ms;
period_filtered = period = 240ms = 0.24s;

In this case, period_filtered(0.24) < min_pedal_period(0.17) is no longer true & hence pedal_rpm would get updated to a value that corresponds to the thread frequency & not to QEP signal frequency. If that is the case the torque would not correspond to the cadence.

Based on the above, update_rate_hz should be a high enough value for the current PAS code to work, right?

@nitrousnrg
Copy link
Contributor Author

Yeah I used pretty high polling frequencies (500Hz), we could set a minimum update rate in vesc tool, or just hardcode it too 500Hz.

Originally I intended to use interrupts, which is why pas_event_handler() was named that way. Interrupts were okay, but made the code diff a bit less clean for no real reason as it worked just fine without them. If someone else wanted to use different pins the change in the isr files would be a somewhat dirty so I settled for the polling approach.

@afzalmam
Copy link
Contributor

afzalmam commented Jan 4, 2021

Thanks for the clarification

@Ecyclist
Copy link

Is PAS build into VESC Tool?
Con you do YouTube video how to set up PAS?
Thank you

@RobertXuChun
Copy link

The PAS app is great. It works when in PAS alone mode. However, I could never make it work in ADC + PAS mode. Only the ADC works when in the combined mode. I think it's due to the pas_event_handler() being polled instead of being invoked from ISR. I could be wrong. But could anyone test this and hopefully solve the problem? Thank you.

@nitrousnrg
Copy link
Contributor Author

When I coded this I only covered the use case where the ADC also has a brake signal:

                case ADC_CTRL_TYPE_CURRENT_REV_BUTTON_BRAKE_CENTER:
		case ADC_CTRL_TYPE_CURRENT_NOREV_BRAKE_CENTER:
		case ADC_CTRL_TYPE_CURRENT_NOREV_BRAKE_BUTTON:
		case ADC_CTRL_TYPE_CURRENT_NOREV_BRAKE_ADC:
		case ADC_CTRL_TYPE_CURRENT_REV_BUTTON_BRAKE_ADC:

In particular I use ADC_CTRL_TYPE_CURRENT_NOREV_BRAKE_ADC.

My idea was to force an immediate motor release when the user applies brakes (many ebikes have brake sensors) because cadance PAS has like 1 second of ramp up / ramp down times and I don't want the motor to keep pushing when you are braking.

My guess is that you are using ADC_CTRL_TYPE_CURRENT which doesn't read the PAS state. Not sure if we should include this mode. Should we?

@RobertXuChun
Copy link

Yeah, you made my day! Thank you so much for your quick and valuable information. I didn't read your code carefully. ;) I did use ADC_CTRL_TYPE_CURRENT and when it didn't work I changed to a duty cycle mode and it still didn't work. Now I understand. I think you should include this mode or provide some tips on using PAS+ADC.

By the way, I adapted your code to make my particular cadence sensor work. It works but not so predictable.. Sometimes the motor simply continue run even I stop pedaling. Could you check the code below and see if it could be improved? Thank you so much for your time.

void pas_event_handler(void) {
#ifdef HW_PAS1_PORT
//const int8_t QEM[] = {0,-1,1,2,1,0,2,-1,-1,2,0,1,2,1,-1,0}; // Quadrature Encoder Matrix
//float direction_qem;
uint8_t new_state;
static uint8_t old_state = 0;
static uint8_t count = 0;
static float old_timestamp = 0;
static float inactivity_time = 0;
static float period_filtered = 0;

//uint8_t PAS1_level = palReadPad(HW_PAS1_PORT, HW_PAS1_PIN);
uint8_t PAS2_level = palReadPad(HW_PAS2_PORT, HW_PAS2_PIN);

new_state = PAS2_level;
if (new_state != old_state)
  count++;

//direction_qem = (float) QEM[old_state * 4 + new_state];
old_state = new_state;

const float timestamp = (float)chVTGetSystemTimeX() / (float)CH_CFG_ST_FREQUENCY;

// sensors are poorly placed, so use only one rising edge as reference
if(count > 1) {
	float period = (timestamp - old_timestamp) * (float)config.magnets;
	old_timestamp = timestamp;

	UTILS_LP_FAST(period_filtered, period, 1.0);

	if(period_filtered < min_pedal_period) { //can't be that short, abort
		return;
	}
	pedal_rpm = 60.0 / period_filtered;
	pedal_rpm *= direction_conf;
	inactivity_time = 0.0;
	count = 0;
}
else {
	inactivity_time += 1.0 / (float)config.update_rate_hz;

	//if no pedal activity, set RPM as zero
	if(inactivity_time > max_pulse_period) {
		pedal_rpm = 0.0;
	}
}

#endif
}

@nitrousnrg
Copy link
Contributor Author

Have you tried longer ramp times? I configured VESC Tool to use 0.3s by default, but then we found that sometimes with shocks or vibrations the pas would be engaged and the motor spin. So we made the up/down ramp to be 1.2sec and the shock issue was removed.
I wonder if that could be your case as well.

Definetively the help page could use some improvement, will try to make it happen on my next vesc tool PR

@RobertXuChun
Copy link

That's very likely. Great tip again. I will try it in another day. I could never figure this out without your advice. Looking forward to your next PR.

@albertomercurio
Copy link

I really like it! i want to test it but i have a 3-wires PAS sensor, with GND, VCC and OUT. Is there any way to make it work?

@RobertXuChun
Copy link

My PAS sensor has 3 wires like yours. You have to adapt the app code to make it work with your sensor, like my code snippet above. Or nitrousnrg may release a new version which incorporates the 3-wire sensor.

To nitrousnrg: My pas sensor is indeed very unreliable. It has 2 hall sensors and 12 magnets, but only 3 wires. Even when I crank the shaft with my hand at home, it will be engaged quite frequently. I can tell this because I connected the signal wire to the tx pin. The led will light when magnet passes.

@afzalmam
Copy link
Contributor

@RobertXuChun Me too have 3 wire sensor. PAS code was adapted to take care of single signal instead of QEP, but I did not face the issues you mentioned about motor running with no pedaling. I then made the changes like you made (your code looked better than mine), still no issue was observed. Note that I am testing without connecting the sensor to pedal, i.e. tested by rotating rotary part of sensor by hand (rather finger). Sensor was part of a bicycle conversion kit, checking signal in oscilloscope, it seems to be a 12 magnet one.

@livello
Copy link

livello commented Aug 13, 2021

@nitrousnrg
photo_2021-08-13_09-22-32
photo_2021-08-13_09-25-17
app_motor_config_livello.tar.gz

Unreliable motor stop after stop pedaling. Every time when stop pedaling motor stops very slowly. I think this is wrong way. Motor must stop immediately after stop pedaling.

@livello
Copy link

livello commented Aug 13, 2021

I guess I need to disable uart. I use default hw_config, no modification of source code.

@bcm0
Copy link

bcm0 commented Aug 15, 2021

@afzalmam @RobertXuChun @albertomercurio Could you please help me to build vesc tool for 3-wire PAS? How can I change PINs so I can use a display on the UART port?

@livello
Copy link

livello commented Aug 15, 2021

@afzalmam did you see the first message? There is an instruction how to change pins. You will face problems with PAS what I mentioned. But if you plan to ride fire or paved roads it will not stop you...

@afzalmam
Copy link
Contributor

@adnion Code snippet by RobertXuChun above in the thread works for me

@afzalmam
Copy link
Contributor

afzalmam commented Oct 7, 2021

@nitrousnrg i have gearless e-cycle and the location here has a lot of high gradient slopes. It was difficult to ride uphill with Cadence control. To make ride comfortable in my situation, a new control type - Constant Torque has been, more details in the pull request - #346, let me know if you have any comments

@TreadMTB
Copy link

TreadMTB commented Aug 3, 2022

Hi guys, Please bare with me being a beginner. I would like to connect the VESC to my Tongsheng TSDZ2, the phase wires and hall connectors are simple enough. How should I connect the torque sensor to the VESC pins for the stock firmware? The TSDZ2 has a torque sensor with only 2 wires, black and red. Where should I try to connect those? If I want to do throttle and PAS would I choose PAS + uart? or just select PAS and constant torque? I will eventually want to try livello's version after I figure out how to get this torque sensor working, so i could use the other SWDIO, SWDCLK pins for PAS instead and have comms for throttle and uart for bluetooth. TIA for the help.

@jon2com
Copy link

jon2com commented Aug 3, 2022

stock PAS implementation in 5.03 runs fine, only I noticed that sometimes it won't stop and you need a new pulse from PAS to make it stop. But I think it is not a big deal.

I have noticed the exact same behaviour

@livello
Copy link

livello commented Aug 4, 2022

How should I connect the torque sensor to the VESC pins for the stock firmware? The TSDZ2 has a torque sensor with only 2 wires, black and red. Where should I try to connect those? If I want to do throttle and PAS would I choose PAS + uart?

@TreadMTB
The pas sensor of TSDZ is two hall based with 24 magnets. It has nice resolution.
https://opensourceebikefirmware.bitbucket.io/development_tsdz2/About_Tongsheng_TSDZ2_mid_drive_motors--Torque_sensor_and_PAS.html

But torque sensor is very complicated. Also, there is no place to hide vesc controller inside motor.

So why you need vesc on TSDZ2? For smooth ride? For more watts?

The best and only way of using torque sensor on TSDZ is to keep stock controller and make him send data from torque sensor to vesc. But it is complicated. You must keep calibration feature...

TSDZ2 has his own open source firmware with a lot of functions.

@livello
Copy link

livello commented Aug 4, 2022

@livello your implementation I played with it a bit, look here:

@rupebac
Thank you very much for feed back!
Unfortunately I'm on my own legs since my shaft is broken. I try to repair and to print another one.

image
image

@geofrancis
Copy link

does anyone have a link to a compatible quadrature PAS ?

@rupebac
Copy link

rupebac commented Aug 4, 2022

does anyone have a link to a compatible quadrature PAS ?

any one for Cycle Analyst V3 should work (there are some links in this thread, check my comments), just power up the PAS with 5V, and trust @jon2con on that 5v is fine on RX/TX lines, or use a 5v - 3.3v converter to step down voltage from the 2 signals of the pas.

@rupebac
Copy link

rupebac commented Aug 4, 2022

@livello your implementation I played with it a bit, look here:

@rupebac Thank you very much for feed back! Unfortunately I'm on my own legs since my shaft is broken. I try to repair and to print another one.

image image

wow, how did it happen?

@TreadMTB
Copy link

TreadMTB commented Aug 7, 2022

How should I connect the torque sensor to the VESC pins for the stock firmware? The TSDZ2 has a torque sensor with only 2 wires, black and red. Where should I try to connect those? If I want to do throttle and PAS would I choose PAS + uart?

@TreadMTB The pas sensor of TSDZ is two hall based with 24 magnets. It has nice resolution. https://opensourceebikefirmware.bitbucket.io/development_tsdz2/About_Tongsheng_TSDZ2_mid_drive_motors--Torque_sensor_and_PAS.html

But torque sensor is very complicated. Also, there is no place to hide vesc controller inside motor.

So why you need vesc on TSDZ2? For smooth ride? For more watts?

The best and only way of using torque sensor on TSDZ is to keep stock controller and make him send data from torque sensor to vesc. But it is complicated. You must keep calibration feature...

TSDZ2 has his own open source firmware with a lot of functions.

I was planning on putting the controller externally to lower the heat in the system. Also this would give the space needed to put water cooling for both. I would love the ability to run 36-72v and throttle + torque sensing PAS. VESC is easily set up with throttle, but I wouldn't want to give up the torque sensing PAS. How can I keep the TSDZ2 controller and have it send it's torque/cadence data to the vesc?
My end goal is to get a torque sensing system working with VESC/mid drive set up for my ebike. TSDZ2 running OSF happens to be a system I already own, that I was hoping to test on. If I can't get it working with the TSDZ2, then I would need to order a torque sensing bottom bracket and hoping I can get it to work. I don't have much experience with the VESC. Doesn't seem to be too many people using it this way, but seeing as there is a constant torque setting under the PAS section of VESC Tool. Could I assume this is possible? Is that the mode I would need to use with a torque sensor?

@TreadMTB
Copy link

TreadMTB commented Aug 7, 2022

does anyone have a link to a compatible quadrature PAS ?

any one for Cycle Analyst V3 should work (there are some links in this thread, check my comments), just power up the PAS with 5V, and trust @jon2con on that 5v is fine on RX/TX lines, or use a 5v - 3.3v converter to step down voltage from the 2 signals of the pas.

I think you should buy some of the original ones from china(be sure to read the specs, most but not all run off of 5v input), they are cheaper priced and also not modified to the higher voltage/price/longer cable by grin tech. Then you can also avoid having to buy that voltage converter in the first place. My statements apply to their torque sensors, I'm not sure about if they have modified the input voltage on their cadence sensors(although I'm sure they put a good mark up on them). TLDR don't buy torque sensors from grin unless you like paying more and having to buy something extra to wire in just to get it back to 5v input.

@rupebac
Copy link

rupebac commented Aug 7, 2022

does anyone have a link to a compatible quadrature PAS ?

any one for Cycle Analyst V3 should work (there are some links in this thread, check my comments), just power up the PAS with 5V, and trust @jon2con on that 5v is fine on RX/TX lines, or use a 5v - 3.3v converter to step down voltage from the 2 signals of the pas.

I think you should buy some of the original ones from china(be sure to read the specs, most but not all run off of 5v input), they are cheaper priced and also not modified to the higher voltage/price/longer cable by grin tech. Then you can also avoid having to buy that voltage converter in the first place. My statements apply to their torque sensors, I'm not sure about if they have modified the input voltage on their cadence sensors(although I'm sure they put a good mark up on them). TLDR don't buy torque sensors from grin unless you like paying more and having to buy something extra to wire in just to get it back to 5v input.

I haven't yet found a quadrature one from china, if you do please put the link. Grin uses these "Kingmeter". I was able to find one in Germany for 25€.

@livello
Copy link

livello commented Aug 8, 2022

@TreadMTB

How can I keep the TSDZ2 controller and have it send it's torque/cadence data to the vesc?

You can make cables longer. Two wires from torque sensor and four wires from hall cadense sensor.
After that you will need to send data from tsdz2 controller to vesc. That could be obtained with nrf52840 chip ble-uart module of TSDZ2. You should add can bus module, you will need to modify tsdz2 nrf52840 code, and you will need create vesc can bus app for retrieve cadence and torque data...

Lot of work. Lot of tests. Weeks, months, depends on your skill.

If you have a lot of time and no money... Go, try.

But much beteer is to buy bafang ultra with vesc-based controller or keep stock one...
TSDZ2 is a lightweight weak motor. 750w is maximum power you should not exceed...

@chuyskywalker
Copy link

chuyskywalker commented Dec 26, 2022

@kylerlaird

It's not "supported" as far as I know, but I use these.
https://www.aliexpress.com/item/33030138390.html

Sorry to ping an old thread -- are you just using the torque output signal directly to, say, ADC1?

@thebrain76
Copy link

I have a Mini Vesc 4.20 with broken mini usb connector.
I only have access via the SWD PIN and an STLink adapter. The firmware flashing works great.
After flashing I can operate the Vescsoftware via Bluetooth over UART port.
A friend programmed me the signal line for a quadrature PAS on ADC and ADC2. This has also worked already.
Problem: when I am connected to controller on a device via Bluetooth, and I select PAS as control sensor, there is no selection PAS+UART.
If I select only PAS, the communication is abruptly terminated. Logically, the BT adapter communicates via UART.

Actually it should run from the connections, if I select ADC and UART, only the software does not start the support for PAS although the connections fit.

When the Miniusbbuchse still went, I could make the engine run via laptop with the newly assigned PIN ADC/ADC2 and the selection PAS.

@thebrain76
Copy link

Can I get a connection from the Vesc tool without mini usb and without Bluetooth(UART), for example about the SWD Port?

@007trains
Copy link

007trains commented Jan 29, 2023

I have a Mini Vesc 4.20 with broken mini usb connector. I only have access via the SWD PIN and an STLink adapter. The firmware flashing works great. After flashing I can operate the Vescsoftware via Bluetooth over UART port. A friend programmed me the signal line for a quadrature PAS on ADC and ADC2. This has also worked already. Problem: when I am connected to controller on a device via Bluetooth, and I select PAS as control sensor, there is no selection PAS+UART. If I select only PAS, the communication is abruptly terminated. Logically, the BT adapter communicates via UART.

Actually it should run from the connections, if I select ADC and UART, only the software does not start the support for PAS although the connections fit.

When the Miniusbbuchse still went, I could make the engine run via laptop with the newly assigned PIN ADC/ADC2 and the selection PAS.

By default the PAS app uses the UART pins for the quadrature sensor, this is the reason there is no PAS+UART app
To get around this you need to reassign the HW PAS pins (your friend has already done this)
And modify adc.c with the code to enable UART on the PAS app:

case APP_PAS:
	app_pas_start(true);
        hw_stop_i2c();
	app_uartcomm_start(UART_PORT_COMM_HEADER);
	break;

@thebrain76
Copy link

thebrain76 commented Jan 29, 2023

@007trains : thanks.

Ok. I am not a professional. Please check my thinking .

In the first step my friend adjusted the hwconf/hw.h. The signal of the QuadraturPAS is now processed by the PIN ADC +ADC2.

Then I would have to select the App Application "PAS" in the Vesctool. So that the connection via BT (UART) still exists another adjustment is necessary.

To get around this you need to reassign the HW PAS pins (your friend has already done this)
And modify adc.c with the code to enable UART on the PAS app:

case APP_PAS:
app_pas_start(true);
hw_stop_i2c();
app_uartcomm_start(UART_PORT_COMM_HEADER);
break;

After that the PAS works on ADC + ADC2 and the controller is still reachable via BT.

Remind: I need the BT connection because my mini USB socket is broken.

Thanks for your help

@thebrain76
Copy link

changes for Quadrat PAS in hwconfig/hw.h:


59A31763-E3A7-44FA-8F81-A31020745F43

@007trains
Copy link

@007trains : thanks.

Ok. I am not a professional. Please check my thinking .

In the first step my friend adjusted the hwconf/hw.h. The signal of the QuadraturPAS is now processed by the PIN ADC +ADC2.

Then I would have to select the App Application "PAS" in the Vesctool. So that the connection via BT (UART) still exists another adjustment is necessary.

To get around this you need to reassign the HW PAS pins (your friend has already done this) And modify adc.c with the code to enable UART on the PAS app:

case APP_PAS: app_pas_start(true); hw_stop_i2c(); app_uartcomm_start(UART_PORT_COMM_HEADER); break;

After that the PAS works on ADC + ADC2 and the controller is still reachable via BT.

Remind: I need the BT connection because my mini USB socket is broken.

Thanks for your help

Yes your correct in your thinking, in order to get Bluetooth working the next step is to add the line:

app_uartcomm_start(UART_PORT_COMM_HEADER);

into adc.c under case APP_PAS:

That will start the UART when the PAS app is selected so you can use Bluetooth to connect to VESC while the PAS app is selected

@sTorrro
Copy link

sTorrro commented Feb 16, 2023

I just found this Pedal assist support (PAS) for vesc. I have been looking for something like this to build my own eMTB with som extra power, especially the ADC part, i feel is missing for most eMTB. When you reach a section where you cant pedal because your pedals will touch the ground it would be nice to push the throttle to get through. Does it work like this? Also I dont mind using a more powerfull moter even tho the motor is limited to 250w, I think by law, for eMTBs, noone will notice as long as I just use the extra power for the throttle on extra technical parts on the trail.

Also, I guess this supports adjustable throttle, regenerative braking and would be most convenient to use on a hub motor, but I wonder if there is any suggestions to make the regenerative braking work on a mid-drive-motor? I was thinking about adding a secound chain on the opposite side of the chain used for pedaling and find some way to activate it when using regenerative braking.

@ReFeXe
Copy link

ReFeXe commented Apr 23, 2023

3 wire pas
I did it!
It works correctly, detects the rotation of the pedals in the opposite direction, provides a smooth start
https://github.com/ReFeXe/bldclcd3/blob/release_6_02/applications/app_pas.c

to work, just set a variable "pas_one_magnet" true

@ReFeXe
Copy link

ReFeXe commented Apr 27, 2023

mistakenly filled in the wrong file. fixed

@livello
Copy link

livello commented Apr 30, 2023

pas_one_magnet

what does it mean? 1 pulse per 1 round? Or 1 hall sensor in pas sensor?
Did you face with problem of too big cadence, more than max value?
And pas_adc still does not work.

@ReFeXe
Copy link

ReFeXe commented May 2, 2023

pas_one_magnet

what does it mean? 1 pulse per 1 round? Or 1 hall sensor in pas sensor? Did you face with problem of too big cadence, more than max value? And pas_adc still does not work.

this variable in my code, changes the operation of the controller to read a 3-wire sensor with 1 hall

Unfortunately, my bike is not ready yet, so I conduct experiments on the table.

@rupebac
Copy link

rupebac commented May 3, 2023

guys, I tried at the beginning of the year, the stock fw 6.0 version, and it still had a very laggy stop (aka, it takes 1-2 secs to cut off power to the motor after stop pedalling). Does anyone know if this has been fixed now in the master branch? is it worth for me to try again ?

@livello
Copy link

livello commented May 4, 2023

@rupebac pas works the same. But new problem arrived, if cadence is higher than max value.

@teodargent
Copy link

guys, I tried at the beginning of the year, the stock fw 6.0 version, and it still had a very laggy stop (aka, it takes 1-2 secs to cut off power to the motor after stop pedalling). Does anyone know if this has been fixed now in the master branch? is it worth for me to try again ?

stock PAS implementation in 5.03 runs fine, only I noticed that sometimes it won't stop and you need a new pulse from PAS to make it stop. But I think it is not a big deal.

I have noticed the exact same behaviour

Have the pas issues been fixed? @livello @rupebac @jon2com

@Sandroforms
Copy link

3 wire pas I did it! It works correctly, detects the rotation of the pedals in the opposite direction, provides a smooth start https://github.com/ReFeXe/bldclcd3/blob/release_6_02/applications/app_pas.c

to work, just set a variable "pas_one_magnet" true

Could you tell me which input did you connect the 3 wires of the pas sensor to the vesc?

@Tukk1S
Copy link

Tukk1S commented Feb 18, 2024

@007trains : thanks.
Ok. I am not a professional. Please check my thinking .
In the first step my friend adjusted the hwconf/hw.h. The signal of the QuadraturPAS is now processed by the PIN ADC +ADC2.
Then I would have to select the App Application "PAS" in the Vesctool. So that the connection via BT (UART) still exists another adjustment is necessary.
To get around this you need to reassign the HW PAS pins (your friend has already done this) And modify adc.c with the code to enable UART on the PAS app:
case APP_PAS: app_pas_start(true); hw_stop_i2c(); app_uartcomm_start(UART_PORT_COMM_HEADER); break;
After that the PAS works on ADC + ADC2 and the controller is still reachable via BT.
Remind: I need the BT connection because my mini USB socket is broken.
Thanks for your help

Yes your correct in your thinking, in order to get Bluetooth working the next step is to add the line:

app_uartcomm_start(UART_PORT_COMM_HEADER);

into adc.c under case APP_PAS:

That will start the UART when the PAS app is selected so you can use Bluetooth to connect to VESC while the PAS app is selected

I cant find case APP_PAS, so im bit confused where to add
`app_uartcomm_start(UART_PORT_COMM_HEADER);
could someone give more detailed instructions?
Thank you!

-TukkiS

@Tukk1S
Copy link

Tukk1S commented Feb 19, 2024

@007trains : thanks.
Ok. I am not a professional. Please check my thinking .
In the first step my friend adjusted the hwconf/hw.h. The signal of the QuadraturPAS is now processed by the PIN ADC +ADC2.
Then I would have to select the App Application "PAS" in the Vesctool. So that the connection via BT (UART) still exists another adjustment is necessary.
To get around this you need to reassign the HW PAS pins (your friend has already done this) And modify adc.c with the code to enable UART on the PAS app:
case APP_PAS: app_pas_start(true); hw_stop_i2c(); app_uartcomm_start(UART_PORT_COMM_HEADER); break;
After that the PAS works on ADC + ADC2 and the controller is still reachable via BT.
Remind: I need the BT connection because my mini USB socket is broken.
Thanks for your help

Yes your correct in your thinking, in order to get Bluetooth working the next step is to add the line:
app_uartcomm_start(UART_PORT_COMM_HEADER);
into adc.c under case APP_PAS:
That will start the UART when the PAS app is selected so you can use Bluetooth to connect to VESC while the PAS app is selected

I cant find case APP_PAS, so im bit confused where to add `app_uartcomm_start(UART_PORT_COMM_HEADER); could someone give more detailed instructions? Thank you!

-TukkiS

Found it!
it's not in adc.c it is in app.c

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

Successfully merging this pull request may close these issues.