Pyboard DAC (x5) (1.8V-2.2V) only?

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
RenierJVV
Posts: 2
Joined: Fri Sep 08, 2017 9:57 am

Pyboard DAC (x5) (1.8V-2.2V) only?

Post by RenierJVV » Fri Sep 08, 2017 11:15 am

Hi, newbie here!

From Docs:

from pyb import DAC
dac = DAC(1) # create DAC 1 on pin X5
dac.write(128) # write a value to the DAC (makes X5 1.65V)

I can only write values from 0-109 with V (x5-->ground) from 1.8V --> 2.2V.
I can not get any values below or above this range.
Similar when set to 12 bits.

Was hoping to read 0-->3.3V for write values 0-->255

Its the same for all 3 pyboards I have.
Any suggestion would be welcomed!

Online
User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: Pyboard DAC (x5) (1.8V-2.2V) only?

Post by Roberthh » Fri Sep 08, 2017 6:59 pm

The follwoing example from the manual works for me, with numbers from 0 - 255 resulting in an output of 0.0 - 3.28V

Code: Select all

from pyb import Pin, DAC

dac = DAC(Pin('X5'))
dac.write(120) # output between 0 and 255
The code lines you used with dac = DAC(1) work too as expected. Is there anything connected to X5 which has impact on the values you see, like a "strange" load?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Pyboard DAC (x5) (1.8V-2.2V) only?

Post by pythoncoder » Sat Sep 09, 2017 5:29 am

Odd that 128 gave the correct result. I suggest linking pins X4 and X5 and trying the following at the REPL.

Code: Select all

>>> from pyb import DAC, ADC, Pin
>>> dac = DAC(Pin('X5'))
>>> adc = ADC(Pin('X4'))
>>> dac.write(128)
>>> adc.read()
2046
>>> dac.write(255)
>>> adc.read()
4075
>>> dac.write(0)
>>> adc.read()
7
>>> 
You won't get exactly the same results owing to tolerances, but they should be close.
Peter Hinch
Index to my micropython libraries.

RenierJVV
Posts: 2
Joined: Fri Sep 08, 2017 9:57 am

Re: Pyboard DAC (x5) (1.8V-2.2V) only?

Post by RenierJVV » Mon Sep 11, 2017 11:56 am

@ Roberthh,
Pins are open, nothing connected!

@ pythoncoder
I ran your suggestion and got:
2049 (your reading 2046)
4073 (your reading 4075)
2 (your reading 7)

This implies all good yes?

Who wants a multimeter for free? (useless readings included free of charge!)

Many many thanx for everyones replies!
R

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Pyboard DAC (x5) (1.8V-2.2V) only?

Post by pythoncoder » Tue Sep 12, 2017 6:45 am

Yes, that looks good. There are several cases where the Pyboard can test itself ;)
Peter Hinch
Index to my micropython libraries.

Post Reply