Przetwornik ADS1256

Miejsce na posty nie związane z powyższymi
ODPOWIEDZ
Awatar użytkownika
Karlos128@nos
Posty: 54
Rejestracja: 18 sie 2015, 13:32

Przetwornik ADS1256

Post autor: Karlos128@nos » 01 gru 2019, 12:52

Witam Panów, otóż moje pytanie dotyczy czy ktoś może już prubował uruchomić bądź uruchomił ten przetwornik w bascomie. Niby są w necie jakieś biblioteki na arduino ale to wiadomo inne środowisko programistyczne.
Wychodzę z tym zapytaniem bo kupiłem taki moduł no ale przydało by się jego chociaż uruchomić na jednym kanale.
Jeśli chodzi o datashet to jest tam jakaś wzmianka o uarcie "Connection to 8xC51 MicrocontrollerUART with a 2-Wire Interface" i jak by to ugryść? :?
Awatar użytkownika
niveasoft
Posty: 1213
Rejestracja: 17 sie 2015, 12:13
Kontakt:

Re: Przetwornik ADS1256

Post autor: niveasoft » 01 gru 2019, 17:07

To zwykłe ADC po SPI
DIN - Data In to MOSI czyli Master Output Slave Input
DOUT - Data Output to MISO czyli Master Input Slave Output
SCLK to zegar czyli SCK
CS to Chip Select czyli SS - Slave Select
Na pinie DRDY masz informację, że dane sa gotowe do pobrania Data Ready
Można więc z tym pogadać sprzętowym SPI, albo programowym a nawet poleceniami Shiftin i Shiftout na dowolnych pinach.


Na pewno trzeba na chwilę usiąść i to skonfigurować ;)
Awatar użytkownika
Karlos128@nos
Posty: 54
Rejestracja: 18 sie 2015, 13:32

Re: Przetwornik ADS1256

Post autor: Karlos128@nos » 01 gru 2019, 17:34

Zanim wyprubuje to może podpowiesz jak zamienić taką składnię poniżej na język bascom
  1. #define SPI_SPEED 2500000
  2.  
  3.  
  4. /* For information to the register and settings see manual page (p..) */
  5.  
  6. /* ADS1248 Register (see p42 for Register Map) */
  7.  
  8. #define    STATUS    0x00 //Status Control Register 0
  9. #define   MUX     0x01 //Multiplexer Control Register 0
  10. #define   ADCON     0x02 //A/D Control Register 0
  11. #define   DRATE   0x03 //A/D Data Rate Control Register 0
  12. #define   IO        0X04 //GPIO Control Register 0
  13. #define   OFC0    0x05 //Offset Calibration Coefficient Register 1
  14. #define   OFC1    0x06 //Offset Calibration Coefficient Register 2
  15. #define   OFC2    0x07 //Offset Calibration Coefficient Register 2
  16. #define   FSC0    0x08 //Full scale Callibration Coefficient Register 0
  17. #define   FSC1    0x09 //Full scale Callibration Coefficient Register 1
  18. #define   FSC2    0x0A //Full scale Callibration Coefficient REgister 2
  19.  
  20. /*STATUS - Status Control Register 0 ( see p30)*/
  21. /* BIT7 - BIT6 -  BIT5   -  BIT4   -  BIT3   -  BIT2   -  BIT1   -  BIT0 */
  22. /* ID   - ID   -  ID     -  ID     -  ORDER  -  ACAL   -  BUFEN  -  DRDY */
  23. #define STATUS_RESET 0x01 // Reset STATUS Register
  24. /*Bits 7 - 4 ID3, ID2, ID1, ID0 Factory Programmed Identification Bits(Read Only)*/
  25. /*ORDER1:0  Data Output Bit Order*/
  26. #define ORDER_MSB B00000000 // Most significant Bit first (default)
  27. #define ORDER_LSB B00001000//Least significant Bit first
  28. /*Input data is always shifted in most significant byte and bit first. Output data is always shifted out most significant
  29. byte first. The ORDER bit only controls the bit order of the output data within the byte.*/
  30. /*ACAL1:0 Auto Calibration*/
  31. #define ACAL_OFF B00000000 // Auto Calibration Disabled (default)
  32. #define ACAL_ON  B00000100 // Auto Calibration Enabled
  33. /*When Auto-Calibration is enabled, self-calibration begins at the completion of the WREG command that changes
  34. the PGA (bits 0-2 of ADCON register), DR (bits 7-0 in the DRATE register) or BUFEN (bit 1 in the STATUS register)
  35. values.*/
  36. /*BUFEN1:0 Analog Input Buffer Enable*/
  37. #define BUFEN_OFF B00000000 //Buffer Disabled (default)
  38. #define BUFEN_ON  B00000010 //BUffer Enabled
  39. /*DRDY1:0 Data Ready (Read Only) Duplicates the state of the DRDY pin*/
  40.  
  41. /* MUX - Multiplexer Control Register 0 (see p31 - bring together with bitwise OR | */
  42. /* BIT7  - BIT6  -  BIT5   -  BIT4   -  BIT3   -  BIT2   -  BIT1   -  BIT0 */
  43. /* PSEL3 - PSEL2 -  PSEL1  -  PSEL0  -  NSEL3  -  NSEL2   - NSEL1   - NSEL0 */
  44. #define MUX_RESET 0x01      // Reset MUX0 Register
  45. /* PSEL3:0 Positive input channel selection bits */
  46. #define P_AIN0 B00000000 //(default)
  47. #define P_AIN1 B00010000
  48. #define P_AIN2 B00100000
  49. #define P_AIN3 B00110000
  50. #define P_AIN4 B01000000
  51. #define P_AIN5 B01010000
  52. #define P_AIN6 B01100000
  53. #define P_AIN7 B01110000
  54. #define P_AINCOM B10000000
  55. /* NSEL3:0 Negativ input channel selection bits */
  56. #define N_AIN0 B00000000
  57. #define N_AIN1 B00000001 //(default)
  58. #define N_AIN2 B00000010
  59. #define N_AIN3 B00000011
  60. #define N_AIN4 B00000100
  61. #define N_AIN5 B00000101
  62. #define N_AIN6 B00000110
  63. #define N_AIN7 B00000111
  64. #define N_AINCOM B00001000
  65.  
  66. /*ADCON - A/D Control Register 0 ( see p31)*/
  67. /* BIT7 - BIT6   -  BIT5   -  BIT4   -  BIT3   -  BIT2   -  BIT1   -  BIT0 */
  68. /* 0    - CLK1   -  CLK0   -  SDCS1  -  SDCS0  -  PGA2   -  PGA1   -  PAG0 */
  69. #define ADCON_RESET 0x20 // Reset ADCON Register
  70. /*CLK2:0 D0/CLKOUT Clock Out Rate Setting*/
  71. #define CLK_OFF B00000000 //Clock Out off
  72. #define CLK_1   B00100000 //Clock Out Frequency = fCLKIN (default)
  73. #define CLK_2   B01000000 //Clock Out Frequency = fCLKIN/2
  74. #define CLK_4   B01100000 //Clock Out Frequency = fCLKIN/4
  75. /*When not using CLKOUT, it is recommended that it be turned off. These bits can only be reset using the RESET pin.*/
  76. /*SDCS2:0 Sensor Detection Current Sources*/
  77. #define SDCS_OFF B00000000//Sensor Detect Off (default)
  78. #define SDCS_05  B00001000//Sensor Detect Current 0.5?A
  79. #define SDCS_2   B00010000//Sensor Detect Current 2?A
  80. #define SDCS_10  B00011000//Sensor Detect Current 10?A
  81. /*The Sensor Detect Current Sources can be activated to verify the integrity of an external sensor supplying a signal to the
  82. ADS1255/6. A shorted sensor produces a very small signal while an open-circuit sensor produces a very large signal.*/
  83. /*PGA3:0 Programmable Gain Amplifier Setting*/
  84. #define PGA_1 //(default)
  85. #define PGA_2
  86. #define PGA_4
  87. #define PGA_8
  88. #define PGA_16
  89. #define PGA_32
  90. #define PGA_64 B00100111
  91.  
  92. /*DRATE - A/D Data Rate Register 0 ( see p32)*/
  93. /* BIT7 - BIT6   -  BIT5   -  BIT4   -  BIT3   -  BIT2   -  BIT1   -  BIT0 */
  94. /* DR7  - DR6    -  DR5    -  DR4    -  DR3    -  DR2    -  DR1    -  DR0 */
  95. #define DRATE_RESET 0xF0 // Reset DRATE Register
  96. /*DR7:0 Data Rate Setting*/
  97. #define DR_30000 B11110000 //30.000 SPS (default)
  98. #define DR_15000 B11100000 //15.000 SPS
  99. #define DR_7500  B11010000 //7.500 SPS
  100. #define DR_3750  B11000000 //3.750 SPS
  101. #define DR_2000  B10110000 //2.000 SPS
  102. #define DR_1000  B10100001 //1.000 SPS
  103. #define DR_500   B10010010 //500 SPS
  104. #define DR_100   B10000010 //100 SPS
  105. #define DR_60    B01110010 //60 SPS
  106. #define DR_50    B01100011 //50 SPS
  107. #define DR_30    B01010011 //30 SPS
  108. #define DR_25    B01000011 //25 SPS
  109. #define DR_15    B00110011 //15 SPS
  110. #define DR_10    B00100011 //10 SPS
  111. #define DR_5     B00010011 //5 SPS
  112. #define DR2_5    B00000011 //2,5 SPS
  113.  
  114. /*IO - GPIO Control Register 0 ( see p32)*/
  115. /* BIT7 - BIT6   -  BIT5   -  BIT4   -  BIT3   -  BIT2   -  BIT1   -  BIT0 */
  116. /* DIR3 - DIR2   -  DIR1   -  DIR0   -  DIO3   -  DIO2   -  DIO1   -  DIO0 */
  117. #define IO_RESET 0xE0 // Reset IO Register
  118. /*DIR3 - Digital I/O Direction for Pin D3*/
  119. #define DIR3_OUT B00000000 //D3 is an output
  120. #define DIR_IN   B10000000 //D3 is an input (default)
  121. /*DIR2 - Digital I/O Direction for Pin D3*/
  122. #define DIR2_OUT B00000000 //D2 is an output
  123. #define DIR2_IN   B01000000 //D2 is an input (default)
  124. /*DIR1 - Digital I/O Direction for Pin D3*/
  125. #define DIR1_OUT B00000000 //D1 is an output
  126. #define DIR1_IN   B00100000 //D1 is an input (default)
  127. /*DIR0 - Digital I/O Direction for Pin D3*/
  128. #define DIR0_OUT B00000000 //D0/CLKOUT is an output
  129. #define DIR0_IN   B00010000 //D0/CLKOUT is an input (default)
  130. /*DIO3:0 Status of Digital I/O, Read Only*/
  131.  
  132. /* SPI COMMAND DEFINITIONS (p34) */
  133. /*SYSTEM CONTROL */
  134. #define   WAKEUP    0x00  //Exit Sleep Mode
  135. #define   STANDBY   0xFD  //Enter Sleep Mode
  136. #define   SYNC    0xFC    //Synchornize the A/D Conversion
  137. #define   RESET   0xFE  //Reset To Power UP values
  138. #define   NOP     0xFF  //No operation
  139. /*DATA READ*/
  140. #define   RDATA   0x01  //Read data once
  141. #define   RDATAC    0x03  //Read data continously
  142. #define   SDATAC    0x0F  //Stop reading data continously
  143. /*READ REGISTER */
  144. #define   RREG    0x10  //Read From Register
  145. #define   WREG    0x50  //Write To Register
  146. /*Calibration */
  147. #define   SYSOCAL   0xF3  //System Offset Calibration
  148. #define   SYSGCAL   0xF2  //System Gain Calibration
  149. #define   SELFCAL     0xF0  //Self Offset Calibration
np.
  1. Const Status = &H00
  2. Const Mux = &H01
czy to by było równoznaczne?
Awatar użytkownika
niveasoft
Posty: 1213
Rejestracja: 17 sie 2015, 12:13
Kontakt:

Re: Przetwornik ADS1256

Post autor: niveasoft » 01 gru 2019, 17:38

Tak. Właśnie tak to czasem przepisuję.
Mogę Tobie podpowiedzieć myk.
Uruchamiasz program Notepad++ i potem możesz dużo rzeczy zamienić z automatu.
Na przykład zaznaczasz "#define" i wciskasz CTRL+R (replace) i w okienku na co to zamienić wpisujesz "Const" :D

Wszystkie 0x możesz zamienić na &H :D i wszystkie "//" na apostrof i tak dalej...

Bascom też ma te funkcje, ale ja dodatkowo mam włączone na stałe "Reformat code" i za dużo by mi do czasu naprawy kodu pozmieniał.
Awatar użytkownika
Karlos128@nos
Posty: 54
Rejestracja: 18 sie 2015, 13:32

Re: Przetwornik ADS1256

Post autor: Karlos128@nos » 01 gru 2019, 17:54

Narazie dzięki. Popracuję nad tym i odezwę się.
Awatar użytkownika
Karlos128@nos
Posty: 54
Rejestracja: 18 sie 2015, 13:32

Re: Przetwornik ADS1256

Post autor: Karlos128@nos » 06 sty 2023, 16:43

Witam szanownych.
Po długim czasie postanowiłem pobawić się z tym ADS1256, ale coś nie za bardzo mi wychodzi ta pogawędka z tym scalakiem.
Opieram się o dataschet oraz gotowe biblioteki lecz nie bascomowe.
Na początek moje pytanko czy dobrze skonfigurowałem interfejs SPI oraz CS i RDY.
Program oparty jest o xmega256a3u.
  1. '*************** Konfiguracja SPI dla ADS1256 24bit ****************************
  2.  
  3. Config Portd.4 = Output                           ' CS=0 aktywny ; CS=1 nieaktywny
  4. Ads1256_cs Alias Portd.4
  5. Ads1256_cs = 1
  6. Config Portd.0 = Output
  7. Ads1256_rst Alias Portd.0
  8. Ads1256_rst = 0
  9. Waitms 500
  10. Ads1256_rst = 1
  11.  
  12. 'On Portd_int1 Rdy_int
  13. 'Enable Portd_int1 , Lo                            'Enable this Interrupt as Lo Level Interrupt
  14. 'Config Pind.1 = Input                             ' T-Q
  15. 'Portd_pin1ctrl = &B00_011_010                     ' _011 Pullup - 010 Reaction on falling edge
  16. 'Portd_int1mask = &B0000_00_10
  17. Rdy_ads1256 Alias Pind.1 : Config Rdy_ads1256 = Input       ' RDY = 1>0 nowe dane
  18. Config Xpin = Portd.1 , Outpull = Pullup , Sense = Low_level
  19.  
  20. Config Spid = Hard , Master = Yes , Mode = 1 , Clockdiv = Clk128 , Data_order = Msb , Ss = None
  21. Open "SPID" For Binary As #15
Następnie próbuje zainicjować układ w taki to sposób:
  1.             Waitms 5
  2.             Ads1256_cs = 0
  3.             Waitms 5
  4.             Bitwait Rdy_ads1256 , Reset
  5.             Print #15 , Ads1256_cmd_wakeup , &H00
  6.             Bitwait Rdy_ads1256 , Reset
  7.             Print #15 , Ads1256_cmd_wreg
  8.             Bitwait Rdy_ads1256 , Reset
  9.  
  10.             Print #15 , Ads1256_reg_adcon , &H00
  11.             Bitwait Rdy_ads1256 , Reset
  12.             Print #15 , Ads1256_reg_drate , Ads1256_drate_5sps
  13.             Bitwait Rdy_ads1256 , Reset
  14.             Print #15 , Ads1256_reg_mux , Ads1256_muxp_ain0 , Ads1256_muxp_aincom
  15.              'Print #15 ,
  16.  
  17.             'Ads1256_cs = 1
  18.             Bitwait Rdy_ads1256 , Reset
  19.             Print #15 , Ads1256_cmd_rdata , 3
  20.             Input #15 , Ads1256_bufor(1)
  21.             Input #15 , Ads1256_bufor(2)
  22.             Input #15 , Ads1256_bufor(3)
  23.             Waitms 5
  24.             Print #15 , Ads1256_cmd_sdatac
  25.             Ads1256_cs = 1
Wstawiam próbke z analizatora fotke PNG.
Czy według was to dobry sposób na komunikacje spi bo wydaje mi się że nic nie odbiera.
Nie masz wymaganych uprawnień, aby zobaczyć pliki załączone do tego posta.
ODPOWIEDZ