board707 / w80x_arduino

w806 package for Arduino IDE
GNU Lesser General Public License v2.1
68 stars 12 forks source link

PWM error #1

Closed AnatolSher closed 1 year ago

AnatolSher commented 1 year ago

Hello! PWM work not correctly. ` // MultiPWM not worked. In this example, PB0 does not work correctly. However, when there is no PWM signal on the other pins, PB0 works fine.

include

include

define DUTY_MAX 250

define DUTY_MIN 50

int pwm_pins[3] = { PB0, PB1, PB2 };

void setup() { //put your setup code here, to run once: pinMode(pwm_pins[0], PWM_OUT); pinMode(pwm_pins[1], PWM_OUT); pinMode(pwm_pins[2], PWM_OUT);

analogWrite(pwm_pins[0], DUTY_MAX); analogWrite(pwm_pins[1], DUTY_MAX); analogWrite(pwm_pins[2], DUTY_MAX); }

void loop() { // put your main code here, to run repeatedly:

for (int pw = 0; pw < 3; pw++) {

for (int i = DUTY_MAX; i > DUTY_MIN; i--) {
  analogWrite(pwm_pins[pw], i);
  delay(1);
}
for (int i = DUTY_MIN; i < DUTY_MAX; i++) {
  analogWrite(pwm_pins[pw], i);
  delay(1);
}

} } `

board707 commented 1 year ago

On what board did you test it - W806 or W801 ?

AnatolSher commented 1 year ago

W806-Kit v1.0 and I have a parallel questions :) where is HAL (vers 0.4.0) tutorial for W806? How can I download it? This HAL is present in the current build. newest version is 0.6.0 - it is true? IMG_20230203_165558

board707 commented 1 year ago

Perhaps there was some misunderstanding between us :) I have nothing to do with the manufacturers of these boards, for me it's just a hobby. So my knowledge is very limited. I only use what I found in the Net.

At the time I don't have an 806 board, only an 801. I will try to figure out the SDK for 806, but if you find something yourself, please write :)

AnatolSher commented 1 year ago

I understood you. It's also a hobby for me. I have an 801 board. And I will check all PWM channels on it.

AnatolSher commented 1 year ago

I checked. The W801 board has the same behavior. Maybe the pin multiplexing is wrong. А по русски здесь писать можно?

board707 commented 1 year ago

Можно :) Но полезнее все же по английски, так как больше народу смогут участвовать.

board707 commented 1 year ago

Did you test for the same issue under windows?

AnatolSher commented 1 year ago

This is independent of the operating system. I have tested compiling and uploading a PWM sketch on both Windows and Linux. Arduino IDE 1.8.19

AnatolSher commented 1 year ago

Странные китайские программисты... :) Странная концепция инициализации пинов в различных режимах... :) Чтобы победить ошибку пришлось сделать так - при каждом вызове analogWrite() инициализировать PWM Понятно что это костыль... Пока пусть будет так, потом ревизию кода делать будем Лишнее за комментировал.

Strange Chinese programmers... :) Strange concept of initializing pins in different modes... :) To defeat the error, I had to do this - with each call to analogWrite () initialize PWM. Banned unnecessary program lines of the function.

image

В данный момент этот скетч работает как задумано This sketch is currently working as intended. image

AnatolSher commented 1 year ago

Привет! Разобрался я почему PWM в многоканальном и одновременном исполнении не работал. Пришлось всю инициализацию переписать. Чуть позже выложу исходники

board707 commented 1 year ago

Привет Я до конца недели в отьезде

AnatolSher commented 1 year ago

Исправлено в HAL 0.6.0