-
-
In my case the problem isn't the WiFi code.
I spent some time adding comments to my code until I isolated the lines that triggered the problem;
Line 3 was the culprit (I included the rest of the SPI configuration commands in case they are relevant)
var spi = new SPI(); spi.setup({mosi: B6 /* D1 */, sck:B5 /* D0 */}); oled = require("SH1106").connectSPI(spi, B8 /* DC */, B7 /* RST - can leave as undefined */, screenReady);
-
My apologies, it turns out that I was mistaken.
After doing a reset()/save() and then a power cycle, pin A0 works perfectly with this command;
analogWrite(A0,0.5, {freq:1});When I stated that a power cycle didn't help I was referring to all previous cases, where I had done a reset(), but not a save(), before cycling the power.
Interestingly I am running wifi code as well, so it could very possible be related to the wifi system.
Regards
Frank -
1) process.version
="1v93"2)dump()
=undefined
(I previously did a reset()/save())3) analogWrite(A0,0.5, {freq:1,forceSoft:true});
This works perfectly4) A full power cycle doesn't make a difference.
Thanks for the offer, but a replacement isn't necessary. I was just worried that I was doing something wrong. I will just switch to using other ports, or use the 'forceSoft' option where necessary.
Thanks for your time and effort in helping me to resolve the issue.
Regards
Frank -
-
1) reset()
2) analogWrite(A0,0.5, {freq:1});
LED flashes on for half a second and then off for half a second and then remains on.3) analogWrite(A0,0.1, {freq:1});
LED stays on4) analogWrite(A0,0, {freq:1});
LED switches off5) >getPinMode(A0)
="af_output"6) digitalWrite(A0, 1);
LED turns on.7) digitalWrite(A0, 0);
LED turns off.8) getPinMode(A0)
="output"6) analogWrite(A7,0.5, {freq:1});
LED flashes on and off for half a second and continues to flash as expected.7) getPinMode(A7)
="af_output" -
I might have answered my own question.
I have a setwatch enabled on 'BTN', and according to the setwatch documentation it appears that pin A0 may be affected by the setwatch command?
Is that maybe the reason for my A0 PWM problem?
Update: it seems that the setwatch command is not the cause of my problem. Even after removing the code there was no improvement in the PWM behaviour of pin A0
-
Okay, time for some feedback.
After spending 2 days experimenting with various hardware configurations and code implementations, and questioning my sanity, I have discovered that using pin A0 does not give me any discernible PWM output variation on my LED, but when I eventually gave up on pin A0 and switched to using pin A7 everything started working as expected.
Since I don't have an oscilloscope (yet) I am unable to do any additional diagnostics, all I can say is that, with exactly the same code, the A0 pin either turns the LED or motor fully on or fully off, yet pin A7 give me the expected PWM variation.
For example, if I use the following code and ramp the value of the 'speed' variable from 0.1 to 0.9 over a few seconds then the LED turns fully on or off at 0.1.
analogWrite(A0,speed, {freq:500});But if I use the same code on pin A7 then the LED and motor ramp up exactly as expected.
analogWrite(A7,speed, {freq:500}); -
-
Hi.
I am using the Espruino WiFi board to control an "L298N Dual H-Bridge Stepper Motor Driver Board".
I want to control the speed of each motor independently, so I decided to apply a different PWM signal to the motor speed control pins "EnA" and "EnB".
I randomly chose two pins on the the Espruino WiFi, which are both documented as PWM-capable: A0 and A7.
But when I use the following commands to set the speeds of the 2 motors they run at different speeds.
analogWrite(A0,0.5, {freq:500});
analogWrite(A7,0.5, {freq:500});If I use only A0 as the control input to EnA and EnB then the motors run at identical speeds.
Am I misinterpreting the PWM features of the Espruino WiFi board?
Thanks
Frank
Awesome.
Thanks!