Combining ADC with Propeller Backpack
bunkerush5
Posts: 10
Hello,
I am currently trying to display the value from an adc0831 as a video overlay using the propeller backpack. I downloaded the adc0831_fast_demo and loaded it to the backpack and using the Serial Terminal I am able to see the values from the ADC. I then tried to add the adc0831_fast _demo code into the PropBP_overlay_demo that I have been able to display a variable with in previous trials. When I added this new adc0831_fast_demo code I did not get any value to display. I think I have a problem with how I implemented the code. Any help would be appreciated. I have included the adc code that works and then my implementation that does not.
original ADC0831 fast demo that works
my version of the propBP overlay demo with the ADC0831 implementation that does not work.
I am currently trying to display the value from an adc0831 as a video overlay using the propeller backpack. I downloaded the adc0831_fast_demo and loaded it to the backpack and using the Serial Terminal I am able to see the values from the ADC. I then tried to add the adc0831_fast _demo code into the PropBP_overlay_demo that I have been able to display a variable with in previous trials. When I added this new adc0831_fast_demo code I did not get any value to display. I think I have a problem with how I implemented the code. Any help would be appreciated. I have included the adc code that works and then my implementation that does not.
original ADC0831 fast demo that works
CON _clkmode = xtal1 + pll8x _xinfreq = 10_000_000 'hardware constants cs = 2 'chip select pin clk = 0 'clock pin d0 = 1 'data pin 'software constants sampleRate = 30000 'adc sample rate (samples/sec) obj pst: "Parallax Serial Terminal" adc: "adc0831_fast" var long adcOut pub go|tmp pst.start(115_200) adc.start(cs,clk,d0,sampleRate,@adcOut) waitcnt(clkfreq*5+cnt) pst.Str(String("adc0831_fast demo",13)) repeat pst.dec(adcOut) pst.newline waitcnt(clkfreq/5+cnt)
my version of the propBP overlay demo with the ADC0831 implementation that does not work.
CON _clkmode = xtal1 + pll8x _xinfreq = 10_000_000 BUF_SIZE = 4096 TPT = 0 'Change this to 1 for video sources that do not work well with 'opaque overlays. TPTor0 = ((TPT == 0) | TPT) & _0 'Commands recognized by "out" method. CLS = $00 '( ) Clear the current window, and home cursor. HOME = $01 '( ) Move cursor to home position. CRSRXY = $02 '(col,row) Move cursor to col and row. CRSRLF = $03 '( ) Move cursor to the left. CRSRRT = $04 '( ) Move cursor to the right. CRSRUP = $05 '( ) Move cursor up. CRSRDN = $06 '( ) Move cursor down. SHODSP = $07 '(dispno) Show display number dispno. BKSP = $08 '( ) Erase prior character and move cursor left. TAB = $09 '( ) Move cursor right to next column divisible by 8. LF = $0A '( ) Linefeed. Scroll up if on bottom line. CLREOL = $0B '( ) Clear to the end of the current line. CLRDN = $0C '( ) Clear from cursor position to the end of the window. CR = $0D '( )Carriage return. Scroll up if necessary. CRSRX = $0E '(col) Move cursor to column col. CRSRY = $0F '(row) Move cursor to row. DEFWIN = $10 '(winno,cols,rows) Define a new window winno sized cols x rows. Make it the current window. USEWIN = $11 '(winno) Change the current window to winno. CHGCLR = $12 '(mask,transparent,fgnd,bkgd) Change current window color to mask, transparent, fgnd, and bkgd. SCROLL = $13 '(offset) Set X (one-line) or Y (multi-line) scroll offset (0 - 15) for current window. SMSCRL = $14 '(rate) Set smooth scrolling rate in current window to rate ms/scan line. WDWRAP = $15 '(yn) Set word wrapping for current window: on (yn<>0) or off (yn==0). BLINK = $16 '(yn) Set blinking for current window: on (yn<>0) or off (yn==0). CPYWIN = $17 '(winno) Copy the text from winno to current window. APNDSP = $18 '(disp,winno,x,y) Append window winno to display disp at location (x,y). MOVWIN = $19 '(slot,x,y) Move window in slot to (x,y). SHOWIN = $1A '(slot,yn) Show window in slot: yes (yn<>0) or no (yn==0). CHGWIN = $1B '(slot,winno) Change window in slot to winno. PRESET = $1C '(dispno,presetno) Create display dispno using preset presetno. SETTIM = $1D '(yr,mo,day,hr,min,sec) Set the current time. MARK = $1E '( )Return MARK to acknowledge reaching this point. ESC = $1F '(char) Escape next character char (i.e. print as-is). CLRWIN = $FF '( )Same as CLS where strings do not permit 0. NONE = $FF 'Same as 0 when used as an argument. ZERO = $FF 'Same as 0 when used as an argument. _0 = $FF 'Same as 0 when used as an argument. NO = $FF 'Same as 0 when used as an argument. YES = $01 'Canonical non-zero value used for binary choices. DBL = $80 'OR with height and width arguments to get double-sized characters. SHO = $40 'OR with window number to set visibility on. 'Preset names. BIGWIN = $01 '40 x 13 regular window. CREDITS = $02 'Vertically overscanned window with smooth scrolling. MARQUEE = $03 'Single row at bottom with smooth scrolling. HILO = $04 'Single rows top and bottom. HILO2 = $05 'Dual rows top and bottom. CROSS = $06 'Single cross-shaped cursor in middle of 40 x 13 screen. BOX = $07 'Single box-shaped cursor in middle of 40 x 13 screen. DOT = $08 'Single dot cursor in middle of 40 x 13 screen. ' Window type names. REGWIN = 0 'Regular window. HMS24 = 1 'Time window: 23:59:59 HMS12 = 2 'Time window: 12:59:59pm YMD = 3 'Date window: 2099-12-31 MDY = 4 'Date window: 12/31/2099 DMY = 5 'Date window: 31-12-2099 YMDHMS24 = 6 'Date/time window: 2099-12-31 23:59:59 MDYHMS12 = 7 'Date/time window: 12/31/2099 12:59:59pm DMYHMS12 = 8 'Date/time window: 31-12-2099 12:59:59pm 'hardware constants cs = 2 'chip select pin clk = 0 'clock pin d0 = 1 'data pin 'software constants sampleRate = 30000 'adc sample rate (samples/sec) OBJ pr : "prop_backpack_tv_overlay2" num: "Simple_numbers_plus" pst: "Parallax Serial Terminal" adc: "adc0831_fast" VAR byte buffer[BUF_SIZE] long x byte lm34temp, temp long adcOut PUB start | i pst.start(115_200) adc.start(cs,clk,d0,sampleRate,@adcOut) waitcnt(clkfreq*5+cnt) pr.start(@buffer, BUF_SIZE) 'pause(2000) pr.str(string(DEFWIN, 10, 40,1,1, CHGCLR, $f,_0, 8|TPT, 1, APNDSP, 10, SHO|10, _0, 20, SHODSP, 10, WDWRAP, 1)) repeat pst.dec(adcOut) pst.newline 'waitcnt(clkfreq/5+cnt) pr.str(num.dec(adcOut)) pr.str(string(" in IDEAL PRODUCTS")) pr.out(CLS) pause(2000) PRI pace(delay, straddr) | ch repeat while ch := byte[straddr++] pr.out(ch) pause(delay) PRI pause(ms) waitcnt(cnt + clkfreq / 1000 * ms) PRI rep(char, reps) repeat reps pr.out(char)
Comments
You're clearing the screen (CLS) right after you display the value, so there will never be enough time to see it. Try swapping the CLS line with the pause line.
-Phil
Thank you that was one of the problems. I was also having problems with the stability when I was watching the overlay on a monitor while the board was still connected to my computer. The image would reset at random intervals especially when the fan would turn on. It is much more stable standalone. Thanks for your help.