Hi Kenpo,
I do not think 628 is going to do it, no ADC.
Hi Kenpo,
I do not think 628 is going to do it, no ADC.
If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
.
Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
.
There simply is no "Happy Spam" If you do it you will disappear from this forum.
sorry, please ignore the ADC code he has in there then.
I have no plans of using ADC.
for now I simply want to send an integer number to an online script.
just a test.
I didn't want to edit his code and risk removing soemthing I shouldn't so it's just a copy/paste
ok, so here's my modified version:
untested, but compiles.
what I am unsure of:
1. how to set the xport with all the funky terminal settings and if it can be done via pbp
2. right now his code waits for a 0 return.
I'd like to receive more than that. ie, the number 55 and then do something like turn a pin HIGH. I'm unsure of how to do that though without breaking it. ie, it's waiting for a 0 return..
sorry for those of you that breath code, this must seem very silly
Code:include "modedefs.bas" @ DEVICE pic16F628A, INTRC_OSC_NOCLKOUT ' System Clock Options @ DEVICE pic16F628A, MCLR_OFF ' Master Clear Options (Internal) DEFINE OSC 4 CMCON = 7 ' pins to define serial RZX and TX tx var portA.6 rx var portA.7 ' pins with LEDs to indicate whether we're connecting ' or sending an HTTP request: httpPin var portb.7 TCPPin var portb.6 output TCPPin output httpPin ' constant to set the baud rate: inv9600 con 16468 ' for non-inverted connections (PIC to Xport direct): true9600 con 84 ' define variables: adcVar var word inByte var byte connected var bit connected = 0 ' pause to let Xport boot up: pause 2000 main: ' if you're connected to the server, then ' make a HTTP call. If not, then connect ' to the server: if connected = 1 then ' read sensors, convert to bytes: adcVar = 55 ' send HTTP GET request for php script: gosub http_request else ' attempt to connect to the server: gosub xport_connect endif tcpPin = connected ' pause so we're not overwhelming the server: pause 3000 goto main xport_connect: ' turn off LED to indicate HTTP GET is in progress: 'low tcpPin ' wait for a "C" byte to come back: while inByte <> 67 serout2 tx, true9600, ["C128.122.253.189/80", 10] serin2 rx, true9600, [inByte] wend ' turn on TCP pin to indicate that we connected: 'high TCPPin connected = 1 return http_request: adcVar = 56 ' light LED to indicate HTTP GET request in progress: high httpPin SEROUT2 TX, true9600, ["GET /xport_test.php?action=insert&"] serout2 tx, true9600, ["sensorValue=", DEC adcVar] serout2 tx, true9600, [" HTTP/1.1", 10] serout2 tx, true9600, ["HOST: brandejs.ca", 10, 10] ' wait for bytes from server: ' php script sends a 0 to end transmission: while inByte <> 0 serin2 rx, true9600, [inByte] wend ' now we're disconnected: connected = 0 ' turn off LED, since GET request is complete: low httpPin return
look at me, spamming my own post...
just wondering, could I do soemthing like change
toCode:while inByte <> 0 serin2 rx, true9600, [inByte] wend
that way I set inByte earlier on as 'z' and then it hangs down below until I get the number 55, or 3 or 0.Code:while inByte == z serin2 rx, true9600, [inByte] wend
I'm imagining grabbing the weather value in degrees off the net for example
(and having my php script only output an integer value, not the extra html filler)
Forget SERIN/SEROUT @ 9600 baud @4MHZ... even worst when dealing with the internal OSC. That PIC have a USART, use it + ceramic resonator + crystal for more reliable results.
You could try DEBUG/DEBUGIN... but there's no advantages over HSERIN/HSEROUT appart the possibility to use Inverted mode.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
that's just what I was thinking here as I was editing the code.
I looked up the manual for the xport so I can now see there's terminal options for setting it up, as well as their software and I can change 9600 to 2400
however I don't really see if it's possible to do all that from the pic. it seems it only needs to be done once? is that right?
I think the 16f628a internal OSC with 2400 should be reliable enough right?
it's a hobby project. I could take it even lower though there's not alot of data being sent.
the last function is now changed to
Code:http_request: adcVar = 56 ' light LED to indicate HTTP GET request in progress: high httpPin inByte = "z" SEROUT2 TX, T2400, ["GET /xport_test.php?action=insert&"] serout2 tx, T2400, ["sensorValue=", DEC adcVar] serout2 tx, T2400, [" HTTP/1.1", 10] serout2 tx, T2400, ["HOST: brandejs.ca", 10, 10] ' wait for bytes from server: ' php script sends anything other than Z to end transmission: while inByte == "z" serin2 rx, T2400, [DEC inByte] wend ' now we're disconnected: connected = 0 ' turn off LED, since GET request is complete: low httpPin return
Last edited by kenpo; - 19th February 2009 at 22:53.
You're using True mode... why messing with bit banged SERIN/SERIN2/DEBUGIN while your PIC have built-in USART???? No advantage at all, and use more codespace as well...
HSERIN/HSEROUT and away you go.
I NEVER use internal OSC when I have to deal with async serial communication. OK OK I hear some "I did it, I still do it and it works all the time" .. well ... good for you![]()
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks