Closed vfear closed 3 years ago
Oh, I forgot to also change the pins here: https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/85552b3e41f383475990a26f85ae4290f571388e/Src/stm32f1xx_it.c#L239-L251 Can you try firmware_PWM_Right_v3.bin?
@EmanuelFeru firmware_PWM_Right_v3.bin zero reaction. The wheels rotate freely by hand. Nothing happens.
I am not sure why is like this.. More debugging is needed. With v2 @vfear you said you had movement but only on one channel?
This vfear was v2, the wheel was spinning with him. My board on v2 and v3 did not react in any way.
no reaction, wheels do not spin on any version (v1 v2 v3 no reaction)
I tried 2 channels - no reaction
What do we do?
I have to fix my mainboard... I accidentally connected the USART 15V to one Tx/Rx pin which burned the MCU with some nice magic smoke :D Luckilly I have few spare standalone STM32 MCUs. Then, I will try to put pwm with an oscilloscope to PB10, PB11 and see what the issue is.
the car is waiting =)))
@EmanuelFeru I think it might actually be the interrupt not working, rather than the timer. Apparently the interrupt line has to be configured differently if you use anything other than the standard PA pins. This blog post describes setting up interrupts on PB12: https://stm32f4-discovery.net/2014/08/stm32f4-external-interrupts-tutorial/
@vfear that looks amazing! @benjaf i agree with you, probably something with the interrupt. I will check the link.
Any progress? I looked to the article and I think bejaf is right, the interrupts need to be remaped too ,we should use IRQ10_15 Handler instead of IRQ2, IRQ3. If I have time I will give it a try these days.
not yet, wait)
@vfear maybe I have the solution now. Can you try firmware_PWM_Right_v4.zip?
@EmanuelFeru v4 work! https://www.youtube.com/watch?v=9A_NA7tQei8
But management has strange behavior. Perhaps my cheap Touring 9 console gives a not very high-quality signal. The right wheel lives its own life, jerks sharply and accelerates forward for no reason. My other console behaves even more sternly, but there the sticks are erased.
With smooth stick control, wheel movements are normal. It is necessary to sharply shift the stick and the wheel spins at maximum speed. Sometimes the noise passes and the wheel accelerates again. And only the left wheel is twitching. The right moves smoothly as it should. Therefore, I conclude that this is a software error in the firmware.
And yet, such a sharp behavior occurs with any connection to the receiver, both in the left port and in the right one.
@marshalab thanks for confirming that the change works. Regarding the way it behaves, activate DEBUG_SERIAL_USART2 (Left cable) and check the value 1: ... and 2: ... see if they are jumping, or not.
Edit: To read the values you need to connect an FDTI, break-out board to read the Serial data.
@marshalab the right wheel seems to behave correctly, so why only left does that.? Is it possible to swap the motors around, to check if still the left does that?
@EmanuelFeru With DEBUG_SERIAL_USART2 enable no PWM compile
Environment Status Duration
VARIANT_ADC FAILED 00:00:01.590 VARIANT_USART SUCCESS 00:00:01.800 VARIANT_NUNCHUK SUCCESS 00:00:01.770 VARIANT_PPM FAILED 00:00:01.548 VARIANT_PWM FAILED 00:00:01.595 VARIANT_IBUS FAILED 00:00:01.585 VARIANT_HOVERCAR FAILED 00:00:01.568 VARIANT_HOVERBOARD FAILED 00:00:01.550 VARIANT_TRANSPOTTER SUCCESS 00:00:01.748 ======================================================== 6 failed, 3 succeeded in 00:00:14.753
Verbose mode can be enabled via -v, --verbose
option
CONFIGURATION: https://docs.platformio.org/page/boards/ststm32/genericSTM32F103RC.html
PLATFORM: ST STM32 6.1.0 > STM32F103RC (48k RAM. 256k Flash)
HARDWARE: STM32F103RCT6 72MHz, 48KB RAM, 256KB Flash
DEBUG: Current (stlink) External (blackmagic, jlink, stlink)
PACKAGES:
^~~~~ In file included from Src\comms.c:6:0: Inc/config.h:477:4: error: #error CONTROL_PWM and SERIAL_USART2 not allowed. It is on the same cable.
^~~~~ In file included from Src\control.c:7:0: Inc/config.h:477:4: error: #error CONTROL_PWM and SERIAL_USART2 not allowed. It is on the same cable.
^~~~~ In file included from Src\main.c:27:0: Inc/config.h:477:4: error: #error CONTROL_PWM and SERIAL_USART2 not allowed. It is on the same cable.
^~~~~ In file included from Src\setup.c:39:0: Inc/config.h:477:4: error: #error CONTROL_PWM and SERIAL_USART2 not allowed. It is on the same cable.
^~~~~
Src\main.c: In function 'main':
Src\main.c:396:28: error: 'pwm_captured_ch1_value' undeclared (first use in this function)
setScopeChannel(0, pwm_captured_ch1_value); // 1: CH1
^~~~~~
Src\main.c:396:28: note: each undeclared identifier is reported only once for each function it appears in
Src\main.c:397:28: error: 'pwm_captured_ch2_value' undeclared (first use in this function); did you mean 'pwm_captured_ch1_value'?
setScopeChannel(1, pwm_captured_ch2_value); // 2: CH2
^~~~~~
pwm_captured_ch1_value
In file included from Src\util.c:26:0:
Inc/config.h:477:4: error: #error CONTROL_PWM and SERIAL_USART2 not allowed. It is on the same cable.
^~~~~ In file included from Src\stm32f1xx_it.c:38:0: Inc/config.h:477:4: error: #error CONTROL_PWM and SERIAL_USART2 not allowed. It is on the same cable.
^~~~~ [.pio\build\VARIANT_PWM\src\bldc.o] Error 1 [.pio\build\VARIANT_PWM\src\control.o] Error 1 [.pio\build\VARIANT_PWM\src\comms.o] Error 1 [.pio\build\VARIANT_PWM\src\setup.o] Error 1 [.pio\build\VARIANT_PWM\src\main.o] Error 1 [.pio\build\VARIANT_PWM\src\util.o] Error 1 *** [.pio\build\VARIANT_PWM\src\stm32f1xx_it.o] Error 1 ============================================================= [FAILED] Took 1.60 seconds
@EmanuelFeru Unfortunately, it was not possible to quickly change the wheels. In a few days I’ll be back and try to swap the wheels. I would like to fully understand the problem.
@marshalab, In my last commit depending on what side you need, you have to select the LEFT or RIGHT input for PWM. https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/d8b529e063b1a03908cd1508e05af5b329eb348b/Inc/config.h#L309-L310
And I just added automatic selection of the DEBUG side according to the PWM input selection: https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/d8b529e063b1a03908cd1508e05af5b329eb348b/Inc/config.h#L311-L314
So, it should be fine.
@vfear maybe I have the solution now. Can you try firmware_PWM_Right_v4.zip?
Works. A little strange sound from the wheels (or so it seems to me=)) but otherwise everything is fine. What do we do now? You need to add a pedal and come up with an algorithm for selecting modes (with a remote and pedals, only the remote or only the pedals).
I think is better if this is done by you according to your needs, because is quite application specific. For example:
if remote is active, you have to decide when to use pedals and when to use remote. How to switch between them.
For simplicity, you can maybe do as you proposed, if remote is at timeout then use pedals, otherwise use remote (if both are connected). All this really depends on the behavior that you want, that is why is better that you implement this logic. Otherwise, there will be too many iterations to reach desired behavior.
have an idea: on the left we connect the gas pedal and potentiometer. with a potentiometer make a choice of modes - P R D (parking, reverse, drive). Parking mode = 0 volts - put the switch in the open of the potentiometer circuit, if = 0 - it is possible to control only through the remote control. if> 0 - control of the pedals and the remote control at the same time, if we lose communication with the remote control - complete stop (parental protection mode) and also: if When you turn on, for 5 seconds we do not see the signal from the remote control - manual control is allowed without using the remote control ( if a signal appears - turn on the parent protection mode again)
addition, make 4 variations 0 (0 volts) - only control from the remote control, parking> 1 volt ... (0 PRD) if we turn it on and within 5 seconds there is no signal from the remote control and the potentiometer> 0 - enable control without remote control, but at when a signal appears, re-enable parental protection
it would be ideal for a baby car, it seems to me. But unfortunately I can’t cope with the code (
Your proposal sounds feasible to me.
👍 question: is it possible to make pwm_deadband more than 100? Now I tested with the remote control 100 a little
yet, sometimes I turn off the remote control without turning off the car so as not to discharge the batteries for several minutes. Then again I want to turn on the remote and continue driving. In your firmware, if I turn off the remote control, an error is triggered (the sound starts to peep) and until you reboot, further movement is not possible. can this be fixed?
@vfear You can increase pwm_deadband as needed. If it is only supposed to be used as backup control, something like 300 would probably be fine. That would certainly prevent the remote from interfering unless you provide quite clear input on the transmitter.
@vfear You can increase pwm_deadband as needed. If it is only supposed to be used as backup control, something like 300 would probably be fine. That would certainly prevent the remote from interfering unless you provide quite clear input on the transmitter.
understandably, it was simply written there from -100 to 100. And on the second question, what can you say?
@EmanuelFeru can I somehow get out of the error “loss of connection with the remote control” without rebooting? and the sound of beeping to remove
Hi @vfear , I am not sure why are you getting beeps from remote timeout
. Because, there is no beep implemented for timeout
from remote. And it should recover once the PWM receiver pulses are back.
Is it maybe interfering with the ADC timeout timeoutFlagADC
? Because, then yes, there is beep on that. However, also from this one the board should recover without the need of a restart.
You may try to disable the ADC protection here:
https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/d8b529e063b1a03908cd1508e05af5b329eb348b/Inc/config.h#L223
But wait also this one is disable for VARIANT_ADC
. I have it enabled only for VARIANT_HOVERCAR
. So, I am a bit confused:
Hi @vfear , I am not sure why are you getting beeps from remote
timeout
. Because, there is no beep implemented fortimeout
from remote. And it should recover once the PWM receiver pulses are back.Is it maybe interfering with the ADC timeout
timeoutFlagADC
? Because, then yes, there is beep on that. However, also from this one the board should recover without the need of a restart.You may try to disable the ADC protection here:
But wait also this one is disable for
VARIANT_ADC
. I have it enabled only forVARIANT_HOVERCAR
. So, I am a bit confused:
which Variant are you using?
and how did you change it to have 2 input methods (ADC and PWM I guess?)
please forgive me, I myself got confused =) I'm watching this on the old firmware
No problem :) Give it a try to the new one.
No problem :) Give it a try to the new one.
checked now on a new one, if I turn on VOLTAGE mode - everything is fine, but if I turn on SPEED mode - then what I wrote above happens. Throws an error signal loss.
No problem :) Give it a try to the new one.
I can’t understand how it is?
I meant to try the latest commits of the FOC branch.
What is the issue you encounter? Is there a moment when turning off remote, where the cmd1 or cmd2 goes a bit crazy? Maybe during turning off. Have a look check with the serial debug activated.
I meant to try the latest commits of the FOC branch.
What is the issue you encounter? Is there a moment when turning off remote, where the cmd1 or cmd2 goes a bit crazy? Maybe during turning off. Have a look check with the serial debug activated.
@vfear I found the issue. It is below.
In case there is a timeout
, the MOSFETs Timer is stopped, but the controller doesn't know that, and it will consider as a defective MOSFET (which if it would really happen, is quite a nasty error, that is why a restart is required).
As a temporary fix, please remove the || timeout > TIMEOUT
in both if
conditions. And I will do a proper fix soon.
https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/68776699e1866b345d1409da3e6148d8956715c4/Src/bldc.c#L117-L129
@vfear I found the issue. It is below.
In case there is a
timeout
, the MOSFETs Timer is stopped, but the controller doesn't know that, and it will consider as a defective MOSFET (which if it would really happen, is quite a nasty error, that is why a restart is required).As a temporary fix, please remove the
|| timeout > TIMEOUT
in bothif
conditions. And I will do a proper fix soon.
Yes, it works now. only if you disconnect the wire on the go - the wheels still continue to rotate
it is very dangerous in case of signal loss
When you disconnect the wire, does not stop? Because it should normally stop after 500ms, according to this: https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/68776699e1866b345d1409da3e6148d8956715c4/Src/control.c#L146-L154
Ah, yes, please remove && timeout < TIMEOUT
, here:
https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/68776699e1866b345d1409da3e6148d8956715c4/Src/main.c#L262
Ah, yes, please remove
&& timeout < TIMEOUT
, here:
yes, now it works well =)
Question: Is it possible to connect 2 motherboards to one receiver in 1 connector? I want to make four-wheel drive. And then when we do the control with the pedal - it turns out just one pedal for 2 boards
@vfear You can do exactly the same for the receiver.
@EmanuelFeru I downloaded the latest firmware, everything is fine! but why did you add sound when there is no signal from the receiver? how to disable it?
For timeout, there should be a sound indicating that something is not ok (for example wire disconnected). Normally, the motors should always receive an input. In case you will use the 2nd input (ADC), it should switch to ADC, so there will be no sound because the input is there.
Anyway, if you really want to disable the Timeout sound completely, comment-out these lines: https://github.com/EmanuelFeru/hoverboard-firmware-hack-FOC/blob/22984a7fd60b164609481768f952b8aa529c6f3d/Src/main.c#L462-L463
For timeout, there should be a sound indicating that something is not ok (for example wire disconnected).
Normally, the motors should always receive an input. In case you will use the 2nd input (ADC), it should switch to ADC, so there will be no sound because the input is there.
Anyway, if you really want to disable the Timeout sound completely, comment-out these lines:
when I turn off the remote control, the receiver also turns off - and the board starts to make a beep sound. Now everything is fine - thanks. (I very often take breaks for several minutes and turn off the remote control so as not to drain the batteries.))
Hello. I want to make a firmware VARIANT_PWM using - RoboDurden's online compiler. Please tell me which lines need to be uncommented? I've commented out the VARIANT_PWM string, but it doesn't work, so I guess I need to do something else?