Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Odd serial data for micromite
Page 1 of 3 | |||||
Author | Message | ||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 911 |
Could anyone think of a way that I might be able to send and receive 1200,7,e,1,N from a Micromite ? Could I receive at 1200,8 read in the data and drop the 8th bit? Graeme |
||||
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209 |
If i read it right, a 1200 baud rate with 7 databits,1 even parity bit and one stop bit has in total 9 bits. If you setup 1200 baud , 8 bits, no parity and one stop bit would also be 9 bits. Receiving is easy as what you already thought. Just drop the 8th bit. Easiest to do an AND with 127 (&B01111111) Sending would require you to take the 7 bit data and use the 8th bit as a parity. For even parity you would need to count the 1's and if the count is uneven then set the parity bit. The count AND 1 will give you a 0 or 1 for even or uneven. Microblocks. Build with logic. |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 911 |
Not having much luck here so I thought I would post my try and see if someone could see the error in my method. Just dealing with the transmit side first, as per the limited documentation I have, the query to acknowledge active for the device attached to the micromite is "a!" at 1200,7,e,1 which I have worked this way: "a"= ASC 97 =1100001 and adding parity bit= 11000010 which= chr$(194) at 8 bits no parity "I"= ASC 73 =1001001 and adding parity bit= 10010010 which= chr$(146) at 8 bits no parity So I am sending the query string as chr$(194)+chr$(146) QUERY$=Chr$(194)+Chr$(66) 'ACKNOWLEDGE ACTIVE a! Pin(7)=1 Open "COM2:1200" As #1 Print Time$; " THE QUERY STRING IS ";QUERY$ Print #1, QUERY$ Pause 100 Pin(7)=0 REPLY$=Input$(10,#1) Close #1 Print Time$;" THE REPLY STRING IS ";REPLY$ Looping the Com2 pins I can see my data back but I cant get a response from the device. Graeme |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8592 |
I think you have put the parity bit at the wrong end - it should be the MSB |
||||
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 3663 |
Also, you probably want a semi-colon (;) at the end of each PRINT #1 (unless you want CR / LF sent as well as your chars) John |
||||
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209 |
"a" = CHR$(97) = 0110 0001 has three ones, use OR 128 (1000 0000) = 1110 0001 (225) "!" = CHR$(73) = 0100 1001 has three ones, use OR 128 (1000 0000) = 1100 1001 (201) Query$ = CHR$(225) + CHR$(201) Not able to test it, but i think those values are right. Microblocks. Build with logic. |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 911 |
Does this mean that a character such as "!" which is ascii 33 &B100001 having even number of ones would still be the same value as the msb will be a zero? |
||||
matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 8592 |
Yes |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 911 |
Thank you for your direction and assistance. Still no response from the device. I might drag out one of my old pc's with a serial port and see if I can pump some life back into it. Will see if I get any response at 1200,7,e with it. Graeme |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5913 |
Try this It's not the most efficient way of adding parity but hopefully it is clear enough to follow. Receiving characters is the easy part. Simply mask off the 8th bit. ch$= chr$(asc(ch$) AND &B01111111)) Jim VK7JH MMedit MMBasic Help |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5913 |
You will also need to include the cr lf pair in the parity code. cr with even parity is chr$(141) lf stays the same. Jim VK7JH MMedit MMBasic Help |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 911 |
Thanks Jim for your code but I think I have a more serious issue with the serial transfer. I am not sure if the response is inverted or modified in some way. I have connected the device to a serial port @1200,7,E,1 with Putty but still don't read a response. I have measured the current draw of the device and it sits at 5mA until I address it, then it raises to 9mA for a short duration. It is either recognising the command and waking from sleep but giving some weird response or it is not recognising the command at all. Not sure what to try from now. Graeme |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 911 |
Found a bit more information that describes the timing required. It seems the device requires a BREAK of at least 12mS then a MARK at least 8.33mS before the command. Tried to upload the diagram but it went to black, sorry. Not sure how to achieve this and still maintain the serial port. Graeme |
||||
robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2290 |
one kludge would be to add a 1k resistor in series with the serial port TxD line. then connect a spare pin of the micromite to the end of the resistor that is away from the micromite. - when this pin is set as input (default) serial transmission can occur as normal, - when set to '0' and output, the TxD line will be forced low, - when set to '1' and output, the TxD line will be forced high, - when set back to input, serial transmission can resume. the 1k resistor allows the pin to 'override' the TxD output. the 3mA required to force a different state to the one TxD is in is well within the drive ability of the micromites I/O pins. cheers, rob :-) |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5913 |
This might be a use for peterm's bitbanger csub. Jim VK7JH MMedit MMBasic Help |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 911 |
@Rob Tried as suggested: QUERY$(1)=Chr$(255)+Chr$(33) 'ADDRESS QUERY ?! QUERY$(2)=Chr$(225)+Chr$(33) 'ACKNOWLEDGE ACTIVE a! QUERY$(3)=Chr$(225)+Chr$(201)+Chr$(33) 'SEND IDENTIFICATION aI! Open "COM2:1200" As #1 For I=1 To 3 Print Time$; " THE QUERY STRING IS ";QUERY$(I);" "; Pin(7)=1 Pin(24)=0 'SET THE BREAK >20mS VIA 1K RESISTOR Pause 20 Pin(24)=1 'SET THE MARK >8.3mS VIA 1K RESISTOR Pause 10 Pin(24)=0 Print #1, QUERY$(I); Pause 200 Pin(7)=0 REPLY$=Input$(10,#1) Print Time$;" THE REPLY STRING IS ";REPLY$ Next I Close #1 Hope I got the BREAK and MARK the right way round. Had a play round with extending the timings but still no go. Graeme |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 911 |
@Jim Currently I have the need to interface these devices into the existing 170 chips and I think that Peter's BitBanger Csub is for the 470 chips. Great thought though. Graeme |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 5913 |
I am using a version of it on the 170 to control some Arlec switches. VK7JH MMedit MMBasic Help |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 911 |
I managed to find another copy of the timing diagram: |
||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 911 |
Jim is that the one that is labelled for the MM+? |
||||
Page 1 of 3 |
Print this page |