Do I have a corrupted memory block?
turbosupra
Posts: 1,088
Ok, after 3 hours of banging my head against the desk, I figured out if I used result := @adc1Result, I get the first screen capture, but if I use result := @adc2Result it works as shown in the second screen capture, that is the only change I'm making. Do I have a corrupted memory block on my protoboard? I'm sorry I can't attach the objects, but the work firewall blocks that.
Also, how can I concatenate this line s2.Concatenate(result, string(ch)) ?
Also, how can I concatenate this line s2.Concatenate(result, string(ch)) ?
{ Have methods 1. collect adc data, format it, save it to globlal variable 2. send global variable values in formated type over serial/method also receives serial data and decodes/updates global variables } CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 CLK_FREQ = ((_clkmode - xtal1) >> 6) * _xinfreq MS_001 = CLK_FREQ / 1_000 con #1, HOME, #8, BKSP, TAB, LF, CLREOL, CLRDN, CR, #16, CLS ' PST formmatting control con RX1 = 31 TX1 = 30 SDA = 29 SCL = 28 CS = 7 CLK = 8 DIO = 9 VAR long numerator long denominator long constantMultiplier long additionAnswer long subtractionAnswer long multiplicationAnswer long divisionAnswer long adc1Result2 long captureAnalogData1Stack[20] Byte adc1Result[128] Byte adc2Result[128] Byte string1value[128] OBJ 'pst : "Parallax Serial Terminal" strings : "Strings" s2 : "Strings2" f : "Float32" fm : "FloatMath" fs : "FloatString" term: "FullDuplexSerial" adc : "jm_mcp3208_ez" PUB Main term.start(RX1, TX1, %0000, 115_200) cognew(captureAnalogData1, @captureAnalogData1Stack) term.str(string("Starting")) term.str(String(13)) repeat waitcnt(clkfreq + cnt) PUB captureAnalogData1 | t, ch, analog, adcNumber, localIndex, zresult adcNumber := 1 localIndex := 0 adc.init(CS, CLK, DIO) ' start adc driver waitcnt(MS_001 + cnt) ' let objects load t := cnt repeat localIndex := 0 repeat ch from 0 to 7 {term.str(string("ch")) term.dec(ch) ' display channel # term.str(string(": ")) term.dec(adc.read(ch, adc#SE)) ' display channel value term.tx(CLREOL) term.tx(CR) term.dec(adcNumber) term.str(string("-")) term.dec(ch) term.str(string(":")) term.dec(adc.read(ch, adc#SE)) term.str(String(13)) } adc1Result~ adc2Result~ result := @adc1Result s2.Concatenate(result, string("1")) s2.Concatenate(result, string("-")) 's2.Concatenate(result, string(ch)) s2.Concatenate(result, string(":")) term.str(string("adc2Result is: ")) term.str(result) term.str(String(13)) 'result := (adcNumber) + (string("-")) + ch + (string(":")) + (adc.read(ch, adc#SE)) term.str(String(13)) term.str(String(13)) waitcnt(t += constant(MS_001 * 500)) waitcnt(t += constant(MS_001 * 500)) ' update every 100ms
Comments
-Phil
Thanks Phil, that did it! What do you usually set your stacks for?
Will only clear the first element of the array.
You should use:
to clear the arrays.