I have this circuit [EDIT: Diagram is NOT complete. { Does not show 5K pulldown on analog channel 1}{Does not show reset 10K pullup}{Does not show piezo connections}] EDITED DIAGRAM
ADDED:the almost red items - moved some items for clarity
The piezo third lead to leg 21 (out 0) - not used in program.
The piezo was taken from a toy. It had three leads. Do not know what the third lead is.
The reset switch is just a stiff wire. I touch it to the 0V for a reset.
and this code
The MCP4725 breakout has I2C pullups in place (10K)
The 5K pulldown on output 7 kills noise on the LCD RXD line when the PICAXE is not running.
P.E. 5.2.7
Now the issue - if it is an issue.
The circuit and code work - (I will optimze/tidy later - I am learning this DAC)
but the I2C DAC output value is always 1 count less than the commanded value
from the pot.
Ex. If the analog value (analog input 0) from the pot is 124, the return analog value (analog input 1) from the I2C DAC will be 123.
I know that this will not influence a scaled value by much, but is there anything that I can do to make the values match?
(Note1: The (wht/ora) wire from Output 6 goes to a piezo used for listening for a resetting picaxe
Note2: The green wire at the bottom is a reset line - I do not yet have a good small pb)
)
SparkFun pages, containing links to pictures, datasheets and schematics
MCP BOARD
LCD DISPLAY
Unfortunately, SparkFun usually has programming examples for ATMEL/C code
ADDED:the almost red items - moved some items for clarity
The piezo third lead to leg 21 (out 0) - not used in program.
The piezo was taken from a toy. It had three leads. Do not know what the third lead is.
The reset switch is just a stiff wire. I touch it to the 0V for a reset.
and this code
Code:
Symbol LCD_CMD_Ext = 124
Symbol LCD_Reset = 8
Symbol LCD_CMD = 254
Symbol LCD_CLR = 1
Symbol Line1 = 128
Symbol Line2 = 192
#no_data
#no_table
setfreq m8
hi2csetup i2cmaster, %11000000, i2cslow, i2cbyte
hi2cout %00000000,(%00000110)
pause 50
serout 7,t9600_8,(LCD_CMD_Ext,LCD_CLR)
PAUSE 20
serout 7,t9600_8,(LCD_CMD,line1,"Signal In ")
serout 7,t9600_8,(LCD_CMD,line2,"Signal Out ")
pause 50
main:
readadc 0,b0
'
'MCP4725 I2C DAC
'Address %11000000 ($C0)
'Mode: Write DAC (C2,C1,C0) -> 0,1,0 (Do not update EEPROM)
'
'12-bit
'ADDRESS
'1st Byte %11000000
'2nd Byte %01000000
'3rd Byte D11-D4
'4th Byte D3-D0,x,x,x,x
'
'1st byte is sent by hi2cout - slave address
'2nd byte is the first position in the parentheses
'3rd byte is b4
'4th byte is b5
'
b4=b0 'copy potentiometer analog value to lo-byte of command value
b5=0 'clear hi-byte of command value
w3=w3*8 'shift left 4 places [EDIT: W3 is the wrong word - the shifting seems to be unnecessary anyway????11-11-09]
hi2cout (%01000000,b4,b5) 'command I2C DAC to generate analog value
readadc 1,b2
'justify the positions of b0 abd b2 on the LCD
if B0<10 then
serout 7,t9600_8,(LCD_CMD,140," ",#b0)
endif
if B0>9 and B0<100 then
serout 7,t9600_8,(LCD_CMD,140," ",#b0)
endif
if B0>99 then
serout 7,t9600_8,(LCD_CMD,140,#b0)
endif
if B2<10 then
serout 7,t9600_8,(LCD_CMD,204," ",#b2)
endif
if B2>9 and B2<100 then
serout 7,t9600_8,(LCD_CMD,204," ",#b2)
endif
if B2>99 then
serout 7,t9600_8,(LCD_CMD,204,#b2)
endif
pause 150
toggle 6
goto main
The 5K pulldown on output 7 kills noise on the LCD RXD line when the PICAXE is not running.
P.E. 5.2.7
Now the issue - if it is an issue.
The circuit and code work - (I will optimze/tidy later - I am learning this DAC)
but the I2C DAC output value is always 1 count less than the commanded value
from the pot.
Ex. If the analog value (analog input 0) from the pot is 124, the return analog value (analog input 1) from the I2C DAC will be 123.
I know that this will not influence a scaled value by much, but is there anything that I can do to make the values match?
(Note1: The (wht/ora) wire from Output 6 goes to a piezo used for listening for a resetting picaxe
Note2: The green wire at the bottom is a reset line - I do not yet have a good small pb)
)
SparkFun pages, containing links to pictures, datasheets and schematics
MCP BOARD
LCD DISPLAY
Unfortunately, SparkFun usually has programming examples for ATMEL/C code
Last edited: