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.
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 08:12am 14 Jul 2016
Copy link to clipboard
Print this post
I'm using a 64 pin Micromite+ V5.2 with a 7Inch SSD1963 Display
I have attached a HC-12 serial uhf module on Com1
I have a program running on a 2nd micromite and it's transmitting data on it's HC-12 , and I have a 3rd HC-12 connected to a TTL converter on the PC.
On the PC I can see the data the 1st Micromite is transmitting, it receives it perfectly.
On the Micromite+ with the TFT I get nothing.
Should this program work?
I'm getting nothing through the console attached to the Micromite+ (I didn't bother trying to get it to display on the GUI till I know the Com port is working correctly.
[code]CLS RGB(blue) 'Clear the screen to a Blue colour
Font 1, 2 ' Set the default font
OPEN "COM1:19200" AS #2 'OPEN COM1 - RF tx/rx From outdoor unit
Do
INPUT #2, A$
Print A$
Loop
End[/code]
I made the code as simple as I could just to see if it will receive and display anything.
IF I just type PRINT "TESTING" then this displays on the console when I run the program, but nothing is showing from Com1
Have I done something wrong, or is the HC-12 attached to the Micromite+ broken?
Edited by lew247 2016-07-15
Zonker Guru Joined: 18/08/2012 Location: United StatesPosts: 767
Posted: 11:12am 14 Jul 2016
Copy link to clipboard
Print this post
Maybe if you check first for incoming characters, then when you have a few in the buffer, then go get them... Is the HC-12 setup correctly..? maybe try a loop-back test on it... (just thinking of stuff to try)...
crez Senior Member Joined: 24/10/2012 Location: AustraliaPosts: 152
Posted: 12:34pm 14 Jul 2016
Copy link to clipboard
Print this post
After very brief consideration, this thought:
Add a semicolon after the print command, otherwise each printed character will be followed by a Carriage Return/Line Feed and will race up the screen before you get a chance to see it.
David
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 11:16pm 14 Jul 2016
Copy link to clipboard
Print this post
I can definitely see the characters scrolling up the screen on the pc console HC-12 so the Micromite+ one should be the same (the "testing" is in a loop so it continually scrolls)
What I need to know is the code I used correct to display everything the COM port is receiving?
Edited by lew247 2016-07-16
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9590
Posted: 11:30pm 14 Jul 2016
Copy link to clipboard
Print this post
Are you connected to the CONSOLE pins, or COM1 on the one you want to talk to?
You MUST have your module connected to the CONSOLE pins and NOT the COM1 pins, if you want to be able to send commands to the MM via the RF module, the RF module needs to be on the console and not COM1.
If you are trying to send data to COM1 for processing by your MM, then COM1 is the correct setup.
If that is the case, then try this test:
Send some data to the MM as you would if you expected it to work.
At the console on the MM, type: ? LOC(#2) If any data has arrived this command will return a non-zero number.
This will indicate if you have any data in the COM1 buffer or not, and then we can go from there, but if you could clarify if you are trying to use the RF module to talk to the console on the MM, or to send data the MM for processing, that would help lots.
Edited by Grogster 2016-07-16Smoke makes things work. When the smoke gets out, it stops!
JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 4036
Posted: 11:31pm 14 Jul 2016
Copy link to clipboard
Print this post
Strictly, no it's not.
Obviously you need Rx/Tx the right way round (plus Gnd), and the baud rate etc need to match, but also so must the incoming line terminator(s).
E.g. say MMBasic wants CR LF but the other end never sends that pair, then you'd see nothing.
JohnEdited by JohnS 2016-07-16
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 11:43pm 14 Jul 2016
Copy link to clipboard
Print this post
Yes it's the COM port that's connected to the HC-12 and the tx/rx pins are correct, the HC-12 is set on the same channel (frequency) and baud rate
I'm guessing I need to replace the HC-12 and try another one
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 12:30am 15 Jul 2016
Copy link to clipboard
Print this post
In simple words (because I tend to make things sound complicated)
Will
INPUT #2, A$
Print A$
Display on the console everything that comes into the com port?
Assuming the com port is open as #2 and set at the correct speed, baud rate and so on?
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9590
Posted: 02:07am 15 Jul 2016
Copy link to clipboard
Print this post
Assuming correct com port/baud rate etc, then yes, that SHOULD input data from the serial port buffer on a line-by-line basis.
I suspect you should be using the INPUT$ function, and NOT the INPUT #2,A$ command.
IE:
A$=INPUT$(LOC(#2),#2) - Suck everything out of the COM port buffer, and stick it into A$.
"INPUT #2,A$" is a command for inputting a list of variables. I would try the INPUT$ function, and you might have more luck. This is what I have always used for reading data into strings from COM ports.Edited by Grogster 2016-07-16Smoke makes things work. When the smoke gets out, it stops!
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 02:25am 15 Jul 2016
Copy link to clipboard
Print this post
ok I'm really stuck with this one
I KNOW the HC-12 is transmitting data at 19200 baud. I know BOTH HC-12's are working and I know both HC-12's are set to the same paramaters. (tested out of circuit and they talk to each other.
I know Micromite #1 is transmitting this string -
I cannot no matter what I try on Micromite #2 to display anything even on the console output.
This is the code on the receiving Micromite
OPEN "COM1:19200" AS #2 'OPEN COM1 - RF tx/rx From outdoor unit
BOX 9,9,780,460,2,rgb(RED) 'Box round screen
Pin(48) = 1 'Set pin of HC-12 High - ie not connected
for X = 1 to 20
Print "Number 1"
A$=INPUT$(LOC(#2),#2)
Print A$
Print "Number 2"
next X
End
The 2 "print Number 1 and Number 2" statements are there for test purposes.
This is what I get on the receive Micromite
The ERROR Is when I tried this version of the code
A$=INPUT$(LOC(#2),#2)
Print A$
I really cannot understand WHY I cannot see what's coming in on the com port?
EDIT:
Forget about the HC-12
What I need is a way to display everythng coming into Com1 on the console output
This is what's not working*
Edited by lew247 2016-07-16
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9590
Posted: 03:39am 15 Jul 2016
Copy link to clipboard
Print this post
I have HC-12 modules here, I will have a play, but they worked fine when I was playing with them.
Number out of bounds suggests there is no data in the com port buffer to be had.
At the command prompt, type: ? LOC(#2) If you get a zero back, then there is no data in the buffer, so you get that error.
Based on the fact that the transmitting HC-12 is outputting data, you should easily get something in the buffer if it is hooked up right.
You mention about having Pin48 high - where exactly does that go to on the HC-12?
You normally don't need to do anything like that - the HC-12 is ready to go right away without pull-ups etc.Smoke makes things work. When the smoke gets out, it stops!
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 03:43am 15 Jul 2016
Copy link to clipboard
Print this post
I have this set high because it's connected to the "SET" pin on the HC-12
The reason for this is so IF I want, I can change the channel the HC-12 is working on through the program, for instance if I want to talk to a remote unit on another channel.
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9590
Posted: 03:46am 15 Jul 2016
Copy link to clipboard
Print this post
Gotcha.
I'll have a play with my HC-12 modules, and see what happens here and let you know.
It SHOULD work fine....
EDIT: What happens when you type in ? LOC(#2) at the command prompt? (with port open and you trying to get results on the receiving MM)Edited by Grogster 2016-07-16Smoke makes things work. When the smoke gets out, it stops!
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 04:11am 15 Jul 2016
Copy link to clipboard
Print this post
0
which I presume it means nothing in the buffer?
I am an idiot by the way - I decided to trace the tracks to the HC-12 module on the transmitting unit - they did not go where they were labelled to go to (I think I changed the layout and forgot to change the silk print)
However with a multimeter and some jumpers I found the correct places where COM1 TX and RX pins are coming out
I HAVE NOW CONNECTED DIRECT to the other micromite with 3 jumpers
TX - RX
RX - TX
GND - GND
But - still getting nothing on the receive Micromite console
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 04:15am 15 Jul 2016
Copy link to clipboard
Print this post
This is the program running on the TX micromite
[code]SetPin 16, DOUT 'HC-12 Power (Connected to COM1)
Pin(16) = 0 'HC-12 Power On
Open "COM1:19200" As #2 'Open port for HC-12 TX/RX
Do
Print "Hello this is the HC-12 talking to you"
Loop[/code]
The receive Micromite is now connected by wires to the tx micromite but still getting nothing at the moment, and the com port tracks on the receive micromite are correct.
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9590
Posted: 04:25am 15 Jul 2016
Copy link to clipboard
Print this post
Yes, a "0" response to ? LOC(#2) means that the MM says the com port buffer is empty.
I would suggest a pause between your print statements - you may well be overloading the buffers of the HC-12 among other things. Something along the lines of PAUSE 3000 or something - a reasonable time delay.
You WILL be overflowing the receiving MM com port buffer with that many test messages at that speed in a loop. The buffer should therefore report it is full with any ? LOC(#2) command!
I will hook up my modules now and have a quick play.
EDIT: Make that tomorrow my time. It is half two in the morning here, so I will call it a night I think.
You appear to be switching the power to the HC-12 with Pin16. I assume this is via a transistor of some kind like a MOSFET?Edited by Grogster 2016-07-16Smoke makes things work. When the smoke gets out, it stops!
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 04:44am 15 Jul 2016
Copy link to clipboard
Print this post
Thanks for the help
Yes the HC-12 is switched with a transistor but please forget about the HC-12 for the moment
BOTH Micromites are connected by WIRED com ports
Both have the ports set to the same paramaters
Both have ports open
I have now put a pause 1000 in the TX micromite program so it transmits the string of characters once a second.
The receiving micromite still isn't getting anything for some reason
The TX and RX pins are crossed in the cable so TX pins goes to RX pins
Both grounds are connected together.
It has to be the program, I just cannot figure out how to display what's coming in on com1
It's got to be the stupidist, simplist problem in the code but I can't figure it out
Grogster Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9590
Posted: 04:54am 15 Jul 2016
Copy link to clipboard
Print this post
I'm still here, being something of a night-owl, but you are right - it should be working. I will have a play with this tomorrow. In the meantime, others may well come up with something else for you to try. Night night. Smoke makes things work. When the smoke gets out, it stops!
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209
Posted: 05:53am 15 Jul 2016
Copy link to clipboard
Print this post
First check if the transmitting micromite is indeed transmitting. You can add a resistor and led to the pin and look for activity.
Also lower the baudrate, 300 if possible to make the pulses longer and easier to detect.
Microblocks. Build with logic.
lew247 Guru Joined: 23/12/2015 Location: United KingdomPosts: 1702
Posted: 05:54am 15 Jul 2016
Copy link to clipboard
Print this post
Just connected the transmitting Micromite to another Micromite+ and it's still not working
I've got one of WW's MicroMite+ Explore 64 and tried it with that as the receive Micromite and it's not working
This leads me to assume it's the code thats wrong "somehow"
Page 1 of 3
Print this page
The Back Shed's forum code is written, and hosted, in Australia.