Shop OBEX P1 Docs P2 Docs Learn Events
Hi, does anyone know ADC demo on Activity Board? — Parallax Forums

Hi, does anyone know ADC demo on Activity Board?

Hello there, I recently tried an ADC demo (jm_adc124s021_demo - Archive) on Activity Board. The ADC uses DIN = 18, DOUT = 19, SCLK = 20, /CS = 21 and BAUD RATE = 115200. After I downloaded and ran from EEPROM, the serial terminal does not seem to display anything, and P30 LED isn't blinking to transmit data to PST. Does anyone know what is going on?
'' =================================================================================================
''
''   File....... jm_adc124s021_demo.spin
''   Purpose.... 
''   Author..... Jon "JonnyMac" McPhalen
''               Copyright (c) 2013-14 Jon McPhalen
''               -- see below for terms of use
''   E-mail..... jon@jonmcphalen.com
''   Started.... 
''   Updated.... 09 OCT 2014
''
'' =================================================================================================


con { timing }

  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000                                          ' use 5MHz crystal

  CLK_FREQ = ((_clkmode - xtal1) >> 6) * _xinfreq
  MS_001   = CLK_FREQ / 1_000
  US_001   = CLK_FREQ / 1_000_000


con { io pins }

' Propeller Activity Board Connections

  RX1     = 31                                                  ' programming / terminal
  TX1     = 30 
  
  SDA     = 29                                                  ' eeprom / i2c
  SCL     = 28 

  R_CH    = 27                                                  ' audio channels
  L_CH    = 26 

  SD_CS   = 25                                                  ' microSD connections
  SD_DI   = 24
  SD_CLK  = 23
  SD_DO   = 22

  ADC_CS  = 21                                                  ' adc connections
  ADC_SCL = 20 
  ADC_DO  = 19 
  ADC_DI  = 18 

  SERVO_5 = 17                                                  ' servo headers
  SERVO_4 = 16
  SERVO_3 = 15
  SERVO_2 = 14
  SERVO_1 = 13
  SERVO_0 = 12


obj

  adc  : "jm_adc124s021"                 
  term : "jm_fullduplexserial"           


var


pub main | t, ch, counts, volts

  setup                                                         ' start objects

  term.rxflush                                                  ' clear term input buffer
  term.rx                                                       ' press key to start

  term.tx(term#CLS)
  term.str(string("ADC124S021 Demo"))

  t := cnt
  repeat
    repeat ch from 0 to 3                                       ' loop through channels
      counts := adc.read(ch)                                    ' read adc    
      volts := 50 * counts / 4095                               ' convert to volts * 10

      term.tx(term#GOTOXY)                                      ' position cursor for channel
      term.tx(0)
      term.tx(ch + 2)
      term.tx(ch + "0")                                         ' display channel
      term.str(string(" : "))                                   ' spacer
      term.rjdec(counts, 4, " ")                                ' channel counts
      term.rjdec(volts/10, 5, " ")                              ' volts 1.0s
      term.tx(".")                                              ' dpoint
      term.tx(volts//10 + "0")                                  ' volts 0.1s                              
       
    waitcnt(t += constant(100 * MS_001))                        ' update every 100ms


pub setup

'' Setup objects and IO used by main cog

  adc.start(ADC_CS, ADC_SCL, ADC_DI, ADC_DO)                    ' connect to adc
  term.start(RX1, TX1, %0000, 115_200)                          ' serial io for termina (PST)

  waitcnt(cnt + MS_001)                                         ' let everything load


dat { license }

{{

  Terms of Use: MIT License

  Permission is hereby granted, free of charge, to any person obtaining a copy of this
  software and associated documentation files (the "Software"), to deal in the Software
  without restriction, including without limitation the rights to use, copy, modify,
  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
  permit persons to whom the Software is furnished to do so, subject to the following
  conditions:

  The above copyright notice and this permission notice shall be included in all copies
  or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MER_CHANTABILITY, FITNESS FOR A
  PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
  CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
  OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

}}

1258 x 706 - 58K

Comments

  • After you open the terminal, are you pressing a key? This code is waiting for you to do that:
      term.rxflush                                                  ' clear term input buffer
      term.rx                                                       ' press key to start
    
  • My bad. After I pressed a key, it works now. Thank you very much!
  • Wow, way to go JonnyMac: 17 minutes after a demo program question is posted, a response from the author!
Sign In or Register to comment.