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!
Pyboard DAC (x5) (1.8V-2.2V) only?
Re: Pyboard DAC (x5) (1.8V-2.2V) only?
The follwoing example from the manual works for me, with numbers from 0 - 255 resulting in an output of 0.0 - 3.28V
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?
Code: Select all
from pyb import Pin, DAC
dac = DAC(Pin('X5'))
dac.write(120) # output between 0 and 255
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Pyboard DAC (x5) (1.8V-2.2V) only?
Odd that 128 gave the correct result. I suggest linking pins X4 and X5 and trying the following at the REPL.
You won't get exactly the same results owing to tolerances, but they should be close.
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
>>>
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Pyboard DAC (x5) (1.8V-2.2V) only?
@ 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
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
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Pyboard DAC (x5) (1.8V-2.2V) only?
Yes, that looks good. There are several cases where the Pyboard can test itself
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.