ao analog out

Play with it! Please tell us which board you're using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
jknoxhcsd
 
Posts: 18
Joined: Mon Nov 04, 2019 1:48 pm

ao analog out

Post by jknoxhcsd »

I am having issues with writing an analog out to A0 in makecode. My goal was to have students write out an analog signal value to a RGB LED to show them how an analog signal works as well as how color works. Anytime we write to A0 in makecode the CPX freezes up and the lights turn to red and blue. We do not have a resistor between the LED and A0 as the output on A1 and A2 are only about 20mA and work great. Ideas? The RGB LED is on a breadboard and the pins are wired directly to the legs of the LED through the breadboard.

User avatar
jps2000
 
Posts: 811
Joined: Fri Jun 02, 2017 4:12 pm

Re: ao analog out

Post by jps2000 »

Teaching students to use a LED without a resistor in series is not so a good idea

User avatar
jknoxhcsd
 
Posts: 18
Joined: Mon Nov 04, 2019 1:48 pm

Re: ao analog out

Post by jknoxhcsd »

True, but the pins only put out about 20mA and would not work at all with a resistor in series. Now, do you have anything of value to add to the conversation?

User avatar
jps2000
 
Posts: 811
Joined: Fri Jun 02, 2017 4:12 pm

Re: ao analog out

Post by jps2000 »

Small resistors like 100 ohms will work.
It will prevent high currents in the moment of switching 20mA is max permanent current.
It may be that those spikes cause a drop in vcc.
So check if the problem is there wihout LEDs connected. ( Check if the loop is still running elsewhere)
How shall someone contribute? You say it halts. There are so many causes. And I am not familiar with makecode.

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: ao analog out

Post by adafruit_support_bill »

True, but the pins only put out about 20mA
That may be the maximum that the pin is rated for, but it is not actively current limited. Exceeding the current rating for a pin can damage the pin.
and would not work at all with a resistor in series.
Not true at all. LEDs will illuminate with well under 20mA.

User avatar
jknoxhcsd
 
Posts: 18
Joined: Mon Nov 04, 2019 1:48 pm

Re: ao analog out

Post by jknoxhcsd »

Thank you for the explanation. I originally had kids start with 220 Ohm resistors (that is what I had available) and the LED wouldn't light up. I almost always have a resistor in the circuit but this one I did not because I had read that the pin was limited to 20mA anyway. My assumption (wrong) was that there must be some type of internal resistor on the pin limiting the current out. Still having issues with A0 though.

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: ao analog out

Post by adafruit_support_bill »

If you post the code you are using and some photos of your setup we can take a closer look.

User avatar
jknoxhcsd
 
Posts: 18
Joined: Mon Nov 04, 2019 1:48 pm

Re: ao analog out

Post by jknoxhcsd »

Just with an analog pin out with nothing attached I get this happening. Clearly I'm doing something wrong or am completely misunderstanding the purpose of the analog out. I did update the boot loader on the CPX.
20220302_082506 (2).jpg
20220302_082506 (2).jpg (477.15 KiB) Viewed 173 times
code.JPG
code.JPG (20.98 KiB) Viewed 173 times

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: ao analog out

Post by adafruit_support_bill »

Have you seen this behavior on more than one of your Circuit Playground boards?

User avatar
jknoxhcsd
 
Posts: 18
Joined: Mon Nov 04, 2019 1:48 pm

Re: ao analog out

Post by jknoxhcsd »

Several yes. Seems to be universal.

User avatar
adafruit_support_bill
 
Posts: 88088
Joined: Sat Feb 07, 2009 10:11 am

Re: ao analog out

Post by adafruit_support_bill »

Let me check with our MakeCode experts . . .

User avatar
jknoxhcsd
 
Posts: 18
Joined: Mon Nov 04, 2019 1:48 pm

Re: ao analog out

Post by jknoxhcsd »

Thank You!!! Purely speculation on my part but pin A0 is "true analog out" whatever that means (I am sure it is digital, just with a higher resolution of outputs and not pwm?) vs the PWM of the other pins. This is causing some type of problem with the code behind the scenes maybe? (wild speculation on my part) My other question is why pin A3 isn't listed as an analog out in Makecode when it is also supposed to be capable of analog out. For anyone else reading this, pins A1 and A2 (and supposedly A3) are actually pwm pins that are only analog in the sense of a pwm average voltage. Pin A3 is not listed as an analog pin out in Makecode.

User avatar
adafruit2
 
Posts: 22144
Joined: Fri Mar 11, 2005 7:36 pm

Re: ao analog out

Post by adafruit2 »

yeah A0 is special! its not actually a PWM out so please use the other pads

User avatar
jknoxhcsd
 
Posts: 18
Joined: Mon Nov 04, 2019 1:48 pm

Re: ao analog out

Post by jknoxhcsd »

Is there a reason A3 is not listed in makecode as analog out? Could the blocks be changed to list A1, A2, and A3 vs 0, 1, 2? It would be nice to have 3 pins for color mixing.

User avatar
adafruit2
 
Posts: 22144
Joined: Fri Mar 11, 2005 7:36 pm

Re: ao analog out

Post by adafruit2 »

do you mind posting a screenshot of what you're referring to?

Locked
Please be positive and constructive with your questions and comments.

Return to “Circuit Playground Classic, Circuit Playground Express, Circuit Playground Bluefruit”