Problems about motor rotation and rotation program
pikasm opened this issue · comments
Hello, I installed the motor and downloaded the scanning program today, but my motor doesn't rotate after downloading. After I set the PWM value of the motor, the motor will rotate a little bit. I want to know what the reason is. Can you help me?
f3bdbb3faf5645c673bdd138f3859237.mp4
de7274f94ae7337a987ba89569a7799f.mp4
I can see that PWM value in Testing Utility get reset to 0.
It does not look OK. Looks like MCU is get reset. Check that your power source can give enough current.
Check power line with oscilloscope.
Can you change PWM when motor is disconnected?
But my power supply is an instrument, and it doesn't indicate that the current is insufficient. Is it possible that the code wheel of my encoder is not the corresponding number of holes, and the motor will continue to run after I need to change it?
I changed the number of holes, but the motor still doesn't work.
When you set PWM manually, motor is not controlled by encoder, it must work in any case.
As I said - check the power line with an oscilloscope when motor is connected.
Motor can take >0.7A at startup.
I had used such board for motor testing in my experiments: https://aliexpress.com/item/1005006219691535.html
I tested the motor, and the initial current was really not big enough. I changed the power supply and the motor can rotate normally. Next, I should install the reference board and set the encoder zero angle. I want to know where the zero angle of the encoder should be stuck. Is it the slit irradiated by the encoder when the lens vertically irradiates the reference plate?
See this page: https://github.com/iliasam/OpenTOFLidar/wiki/Encoder
Check encoder output with an oscilloscope.
Ensure that zero pulse is visible.
Ensure that signal amplitude is > 1.2.
I checked these two values, and there is no problem. Maybe I should change the start angle and stop angle?Because my code dial is 100 yards.
Can you publish your oscilloscope screen image with zero pulse visible?
I don't think that problem is in software.
State mask 0x8 is problem with encoder pulses.
You can see here: https://github.com/iliasam/OpenTOFLidar/wiki/Encoder
that "zero pulse" is keeping high polarity with my hardware.
Zero position -> no light -> no current through opto-transtor -> Encoder output is pulled high by pull-up resistor.
State mask: 0x28
You can see here: https://github.com/iliasam/OpenTOFLidar/wiki/State-Mask-bits-description
bit3 (0x8) - Wrong number of encoder events. Encoder is dirty or wrong installed
bit5 (0x20) - Mirror speed is too low or too high
There is problem with your encoder.
Should I change the encoder next? Does my code wheel need to be replaced?
Check output of the encoder with oscilloscope (at the line at main Lidar PCB).
Ensure that opto-interrupter output in at high state when opto-interrupter light is closed.
You can try to use logic analyzer to capture data from encoder and calculate count of pulses between two zero events.
Maybe yes. You can try to change position of the opto-interrupter sensor.
Have you changed "ENCODER_HOLES_CNT" value in your code to "20"?
yes
Do I need to calibrate the walking error again after downloading the scanning program?
I have increased the encoder timeout millisecond value to 10.
Strange situation.
It looks like that you are receiving "DIST_MEAS_NO_SIGNAL_VALUE" for all points. This happens when you have TDC timeout.
Did you try to run "not_scanning_fw" with mirror installed?
In any case, it will be useful to program "not_scanning_fw" again and confirm that distance measuring is working or not.
I downloaded the not scanning program again, and the distance measurement is effective, but the error is 1cm-2cm larger than before.
My measurement under the installation mirror is like this
Is it possible that I am using the wrong iar version? I used 9.30.1.
Measurements with mirror installed are looking OK, so it looks like that distance measurement HW is working OK.
My IAR is 7.50, but I don't think that problem is connected with that.
Can you load "scanning_fw" again and check with oscilloscope that you have pulses at "LASER_PULSE" line (motor must be running, encoder must be connected)?
I found the problem. There was no laser pulse. After I downloaded the not scanning program, there was a laser pulse. After downloading the scanning program (after downloading the not scanning program), there was a flashing pulse signal at first, but when I turned on the radar rotary scanning program, there was no correct point, and the pulse disappeared at this time. How should I solve this problem?
Sorry, I don't understand your description well.
As I can understand, you say, that "LidarScanningTest" is making pulses disappear?
Can you describe step by step, what you are doing?
Does motor start running after power on without any commands from PC with "scanning_fw" ?
Is the problem repeatable after Lidar power reset?
Do problem exists if you disconnect wire from PCB RX connector (so MCU can only transmit, but not receive)?
I mean, after downloading the scanning program, the pulse signal of the laser began to disappear gradually. Causing me to have no value after rotation measurement.
Every time I use the motor, I will set a pwm value and then measure the rotation; The motor does not rotate when it is energized (it stops every time it is energized).
There is really no pulse, and I don't know why.
"Every time I use the motor, I will set a pwm value and then measure the rotation; The motor does not rotate when it is energized (it stops every time it is energized)."
I don't understand what do you mean by that.
I mean, every time I connect the power supply, the motor will not rotate, and then I will use the LidarTestingUtility program to set the PWM value of the motor, and then the motor will start to rotate.
You can press yellow "Save to Flash" button at the "Main" page of the "LidarTestingUtility" to save motor settings, so motor will be enabled after Lidar power on.
I have saved the pwm value of the motor, and there is really no laser pulse when using it.
Can you check PA2 pin with oscilloscope (P8 pad, see "PCB_3D_view_up.png"). Motor must be running.
This is test output, MCU set this pin to 1 during reading measurement from TDC.
This is looking like a mess, can you give a single measurement, with 1ms in a horizontal grid step?
I need "1 ms", not "10 us" horizontal grid step.
Sorry, I misunderstood. Please wait for me for a while. I'm outside now. I'm very sorry.
I found a magical thing: 1. First of all, I connected the power supply, the motor worked normally, and there was a J1 echo signal. I tried to measure it with LidarScanningTest, and the results were all wrong. 2. Next, I open the LidarTestingUtility for debugging. At this time, the echo signal disappears.
3. I reopened the LidarScanningTest program. At this time, the echo signal still won't appear.
4. I disconnected the power supply, then reconnected it, and there was an echo signal at J1.
Do you have any ideas?
P8 is looking OK. Period is really need to be near 110us if mirror has 12Hz frequency.
So MCU is processing encoder data OK, calculate motor speed OK, one pulse is lasts 30us, so looks like MCU is really trying to read TDC values. So if you see long (>20us) pulses at P8, you must see synchronous laser pulses at J2.
But I need more time for my own experiments to measure real duration.
You can see in "CAPTURE_TIMER_IRQ_HANDLER", how it is working.
As I advised, you can try to test Lidar with RX pad disconnected, so PC can't affect to FW.
I build scanning FW for 20 holes, you can try it: scanning_20_holes.zip
Always check "State mask" value in utilities. It is important thing to understand Lidar internal state.
"State mask" is updated by requests from PC only.
Thank you very much. Can you teach me how to use scanning FW for 20 holes?I'm a computer novice.
You don't know what to do with HEX file?
Use "STM32 ST-LINK Utility" - https://youtu.be/Zim3ANT_tSE?t=143
Yes, thank you for your help. I'm going to study.
I studied it. Do you mean that I downloaded this hex file to the single chip microcomputer through the STM32 ST-LINk Utility program?
Yes.
Is it possible that my single-chip computer or TDC has too much data to process, so there are many wrong points?Because my not scanning measurement is always no problem.
"Is it possible that my single-chip computer or TDC has too much data to process, so there are many wrong points? Because my not scanning measurement is always no problem."
No, I don't think so.
I need time to think about this problem.
I measured P8 pulse length at my Lidar - it is near 40us, as at yours. So it looks like that your Lidar is trying to read measurements and start new pulses.
Can you check simultaneously P8 line and J2 (laser current) lines by oscilloscope? Do J2 signal disappear or not?
Also, you said that J1 (APD) signal disappear. But do J2 (laser) signal disappear too?
Because the school will have a power outage in recent days, I started to go home at four o'clock this afternoon. I just got home. I will take this test in fifteen days. Thank you for your help. You are an excellent teacher.
I seem to have tested this at 2:00 this afternoon, both J2 and p8 signals are present. The J1 signal disappeared because the laser was not emitting light at that time. But I don't think that's the main problem, because when I tested it this afternoon, I found that even if the laser lights up, scanning program measurements are also incorrect.
It still has no measured value.
I found a phenomenon: when I open the test program, the signal at j2 will disappear. At this time, I close the test program and open the rotation program, which will display images, but the measured points are all wrong. After that, I turned off the power supply and then turned it on again, and the signal at j2 reappeared. At this time, I directly opened the rotation measurement program, and I found that the points it got were still wrong. I wonder if you have the phenomenon that j2 signal disappears?
I don't need "Measurement Summary" images - the are not informative, because signal is not periodic.
Also, it is problematic to say something about P8 and J2 pulses - it is a mess at the screen.
I'm asking you to write - is motor is working or not when you are making measurements.
I need time to do my own tests, it for me it is not OK that laser pulses at J2 disappear.
"when I open the test program, the signal at j2 will disappear"
Can you tell, with operations you are doing in the program?
A don't think thing that J2 disappear just after starting TDC_Testing_v1.exe .
" I only opened the radar test program. When I click open, the j2 signal disappears directly. You can see the picture below."
I don't believe you.
I can see that "Auto Request Batch" and "Auto requests" switches are set. They are disabled by default.
Before I clicked open, I checked "Auto Request Batch" and "Auto requests".
I just retested it. When I don't check "Auto Request Batch" and "Auto requests" , the pulse will not disappear.
Batch measurements are designed for non scanning mode, so FW can work wrong then you are sending "Batch request" to the scanning LIDAR. LIDAR pulses can't be controlled by encoder and "Batch request" simultaneously.
Ok, I see. Thank you very much. I can't find the problem now. It still has no result. Do you have any ideas?
When I just adopted the radar rotation measurement program v1.1, I found that the State Mask is 0x0 in general. In rare cases, the State Mask is 0x10.
I found that my Scan Freq is unstable, and it will change between 12 and 17.
The target motor speed I set is 13 RPS.
0x10 appears after the motor speed is abnormal. Under normal circumstances, the motor speed is between 12 and 13. When the speed is abnormal, the maximum speed will reach 17, generally changing around 14-15.
"In rare cases, the State Mask is 0x10." It is Motor stopped flag, it can appear if encoder is not working stabile.
"I found that my Scan Freq is unstable, and it will change between 12 and 17.'
If you are talking about value in LidarScanningTest1 Utility - that value is calculated by utility from duration between packets, it can be unstable.
More accurate value is at "TDC_Testing_v1" utility at the motor page - "Motor Speed".
I checked the "TDC_Testing_v1", and it showed that the motor speed was between 12 and 15.
Is this normal? The speed of the motor is only stable occasionally for a period of time and often changes.
Try to set motor PWM manually in TDC_Testing_v1 and check how motor is working.
Minimal speed of my motor is 12.8 RPS at ~350 PWM, motor is rotating at same 12.8 RPS at lower PWM values.
So it is useless to set smaller value in "Motor Target Speed".
When manual PWM is used, my displayed "Motor Speed" value is stable, it can jump in 0.1 RPS range.
If your "Motor Speed" value with manual PWM is jump > 1RPS and not getting stabilized - it looks like a problem with encoder.
By setting the PWM value, my motor speed is normal: I set the PWM value to 350, and the corresponding radar speed becomes 12.8-12.9 RPS.
But now the points in the scanning test program are still all wrong.
I was wondering if it might be the encoder. I observed our encoder waveform and found two differences.
- Your waveform seems to be a triangle wave, while mine is a square wave.
- Your zero position is higher than other positions, and my zero position is the same as other positions.
Are these two differences likely to cause the program not to recognize my angle value? Because there is nothing wrong with my j1, j2 and single-chip signal reading. And there is a distance result when the motor is not rotating.
"By setting the PWM value, my motor speed is normal: I set the PWM value to 350, and the corresponding radar speed becomes 12.8-12.9 RPS."
I recommend you to keep using this manual mode. Don't forget to save motor settings by pressing "Save to Flash" button.
MCU is using internal comparator: https://github.com/iliasam/OpenTOFLidar/wiki/Encoder
"Comparator reference voltage is 1.2V"
So signal amplitude should not affect to encoder pulses decoction.
I have saved the manual values to Flash.I'm a little confused about my problem.
I have no idea.
I don't know why I didn't rotate the scanned image.I'm sad.