I have some problem with DAC121C085 Odroid C2 controlling.
I control two DAC's with using I2C bus (DAC1 slave addr = 0x48, DAC2 slave addr = 0x4e).
There is Python source code below. I use Smbus-library, for the generating onepolar-SIN analog sygnal on the DAC output pin (pin 6 of DAC121C085).
Analog sygnal, wich corresponded to this situation is represented in Fig.1.
When I changing row DAC1_sin_val=DAC_value_array[Time_count]
on DAC1_sin_val=DAC_value_array[Time_count]/4, I get analog sygnal wich is represented in Fig.2.
In the second case the volue of DAC's digital input sygnal are less then 256, and corresponds to the one-byte digital sygnal.
Thus, when I write one byte -signal in DAC I have success - I generate correct analog sygnal (one-polar SIN). But when I use more than one-byte input digital sygnal - I generate incorrect analog sygnal
So, it seems like I incorrect use bus1.write_word_data() - istruction.
What is the problem? How can I correct use bus1.write_word_data() - istruction?
Thanks
Fig_1 => https://cdn1.imggmi.com/uploads/2019/6/10/b0c65d6deee51a50551a29084e682269-full.jpg
Fig_2 => https://cdn1.imggmi.com/uploads/2019/6/10/9a69f5bfdd6b5a352dec2279a54852ae-full.jpg
#!/usr/bin/env pythonimport numpy as npimport cv2import smbusimport timedef nothing(x): passDAC1_value=0K_calib_adc=1.0DAC_value_array = [ 19, 36, 55, 72, 91, 108, 125, 144, 161, 179, 196, 213, 231, 248, 266, 283, 301, 318, 334, 352, 368, 384, 401, 417, 434, 450, 465, 482, 497, 512, 529, 543, 559, 574, 588, 603, 617, 631, 646, 659, 673, 687, 699, 712, 725, 738, 750, 762, 774, 786, 797, 808, 819, 830, 840, 850, 860, 870, 879, 888, 896, 905, 914, 921, 929, 936, 944, 951, 957, 963, 969, 975, 980, 986, 990, 995, 999, 1003, 1006, 1009, 1012, 1015, 1017, 1019, 1021, 1022, 1023, 1023, 1023, 1023, 1023, 1023, 1022, 1021, 1020, 1019, 1017, 1015, 1012, 1009, 1006, 1003, 999, 995, 990, 986, 980, 975, 969, 963, 957, 951, 944, 936, 929, 921, 914, 905, 896, 888, 879, 870, 860, 850, 840, 830, 819, 808, 797, 786, 774, 762, 750, 738, 725, 712, 699, 687, 673, 659, 646, 631, 617, 603, 588, 574, 559, 543, 529, 512, 497, 482, 465, 450, 434, 417, 401, 384, 368, 352, 334, 318, 301, 283, 266, 248, 231, 213, 196, 179, 161, 144, 125, 108, 91, 72, 55, 36, 19, 2 ]#------Peremennie--------------Time_count = 1DAC_arr_index = 0#------------------------------cv2.namedWindow('frame', cv2.WINDOW_OPENGL)# create trackbars for PWMcv2.createTrackbar('DAC_man','frame',0,50,nothing)cap = cv2.VideoCapture(0)#---------------I2C_debug-------------bus1 = smbus.SMBus(1) DAC1_i2c_addr = 0x48 #Motor driver_DAC1 slave addrDAC2_i2c_addr = 0x4e #Motor driver_DAC2 slave addr#-------------------------------while(True): Time_count = Time_count + 1 #------DAC_setting---------- DAC1_manual_value= cv2.getTrackbarPos('DAC_man','frame') DAC1_sin_val=DAC_value_array[Time_count] bus1.write_word_data(DAC1_i2c_addr, 0x00, DAC1_sin_val) bus1.write_word_data(DAC2_i2c_addr, 0x00, DAC1_sin_val) #--------------------------------------- # Capture frame-by-frame __, frame = cap.read() #----------Result_showing------- cv2.putText(frame, "DAC_1",(10,30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 1) cv2.putText(frame, "{:.0f}".format(DAC1_sin_val),(170,30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 255, 0), 1) if (Time_count == 179) : Time_count = 1 ##------------------------------ cv2.imshow('frame',frame) k = cv2.waitKey(5) & 0xFF if k == 27: break if cv2.waitKey(1) & 0xFF == ord('q'): break # When everything done, release the capturecap.release()cv2.destroyAllWindows()