|
Forum Index : Microcontroller and PC projects : Real-Time Communications MM to PC
| Author | Message | ||||
| Andrew_G Guru Joined: 18/10/2016 Location: AustraliaPosts: 872 |
Hi, I'm seeking suggestions as to how best to undertake my proposed next sub-project. I want to use a MM to read incoming ASCII sentences from an HC-12 network and pass them through (eg via wire?) to a PC where I will read the sentences and display the information. My laptop (Windows XP) has a real serial port and I can write the code (QB64) to read and write to it, and display the information. I'm thinking that the MM and an HC-12 would be in a box wired to the PC. I am most uncertain about: a) how to communicate between the MM and the PC (RS232 or USB or ?? - if so how?) b) how to power the MM and HC-12 (I'd rather not have a USB connected to either the PC or a 5V power pack just for power (it would be OK if it was the comms too) as I'm worried about multiple earths and additive 5Vs - I've seen enough smoke for a while . . .). Does anyone have any experience in this or any suggestions? Thanks, Andrew {By way of explanation, I have an HC-12 network with eight temperature sensors scattered around the house (most using BigMick's great MuP3s) and a weather station (wind/rain/temperature/humidity - based on Mike O's code (thanks again)) - all reporting to a base station that measures/graphs barometric pressure each hour over 10 days. It uses a GPS to broadcast date/time to all stations every two hours. It also has a 2.8" LCD to display it all. The base station will end up in a hallway (on a different floor) so I'd like to also show the information on my PC - hence the thought of one more HC-12 "listner" connected to the PC. I think I can do the MM and PC code - it is the bit in between I am unsure about} |
||||
Grogster![]() Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9750 |
You can get USB HC12's - an HC12 in a small enclosure with a USB plug: LINK You plug these into a USB port, and configure the same way as the discrete modules, then it can just hang off a USB port, and monitor your network. Other then that, just about any USB-serial adaptor will do the job for you, such as a CP2102 or a 1455 chip. My HC12 tester/programmer PCB would also do this for you. If you have to use an old RS232 port(9-pin "D" serial port), then you can use the likes of a MAX3232 module such as this one. Smoke makes things work. When the smoke gets out, it stops! |
||||
| Andrew_G Guru Joined: 18/10/2016 Location: AustraliaPosts: 872 |
Hi Grogs. That is most helpful. I had no idea the USB-HC-12 existed - very useful, one wouldn't need the MM. I'll get one (at least). Potentially limited by the coil antenna (I am using more external ones now and getting better range). I have some spare USB-TTL adaptors so I'll give that a go too. Many thanks, Andrew PS are others doing something similar? |
||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
me neither - built my own and thought how clever I was HC-12+CH340G in a tiny case.Incidentally, this is how several networks of 'mites talk back to their PC-based controllers (snooker hall light controllers+feedback pods). Each light module has a SSR and a 'mite with a HC-12 and gets messages from the PC host (and can pass back info if needed). I also broadcast time from the PC so each module doesn't need a RTC chip. |
||||
Grogster![]() Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9750 |
[Quote=Andrew_G]Potentially limited by the coil antenna (I am using more external ones now and getting better range).[/Quote] You can carefully open the USB case, and fit one of those U.FL to SMA socket leads, and put any SMA antenna you like to it. LINK.Smoke makes things work. When the smoke gets out, it stops! |
||||
| Andrew_G Guru Joined: 18/10/2016 Location: AustraliaPosts: 872 |
Grogs you're a star! I have two USB HC-12s on order and a brace of socket leads due to land any day soon. So if I set the USB to match my network (by pressing its Set button and using Rob's program) it will show up as Comm X on Device Manager? How do I access the data passing through (I assume opening Comm X and reading its input). In simple terms HyperTerminal but in due course my own program? Cheers, Andrew |
||||
| pjmart Newbie Joined: 13/11/2016 Location: AustraliaPosts: 9 |
Hi Andrew, I am doing something similar with two Micromites with HC12's on front and back rainwater tanks located beside a garage and a back shed. Originally I intended to use an MM in the house to gather daily readings/summaries from each and then save to its SD card for later transfer to my Windows 10 computer for saving/graphing, etc. Then I found I could eliminate the middle step by using MMBasic for DOS in place of the Maximite. MMBasic has quite good file handling and can save CSV files for import into Excel, etc. The only thing I had to do was slow down the COM port by using 200 to 250 mSec delays between port commands - reads/writes, etc. Each system is located about 30m from my computer with several brick walls in between. The simple spring antenna on each is adequate. I do use a CRC check on each line and request resend if an error is detected as suggested elsewhere on this forum. I can easily read transfers of some 200 lines without a problem. I have found the PC always uses the same COMM port (whilst the USB/HC12 remains plugged in) which I originally located via Terraterm. No need to go to Device Manager. Finally I have set up a Windows single line batch file to load MMBasic for DOS and run my Basic program (which has its own menus, etc). The good thing about all this is that MMBasic for DOS and the your communication program is portable and will work on any PC you load it on. |
||||
goc30![]() Guru Joined: 12/04/2017 Location: FrancePosts: 435 |
You have two problems to solve, hardware and software hardware: support choice: rs232, usb, centronic (if you have this connector). in the first two cases, the choice is simple. I have a preference for rs232 because it's easier to drive, especially in XP Software: you have to choose between several solutions 1 - transparency of the communication: in this case what enter resort without modification, it is the simplest 2 - simple buffer: the card records in a fifo stack the frames exchanged with the sensor and sends back to the request of the pc the values buffered. In this case, you can work in asynchronious timing 3 - Communication protocol: In this case the card is to be slave and responds to the orders of the Pc.If you want to put several sensors each with an HC12, I advise you the modbus protocol, which is knowen and very reliable. It supports multi-point communication in long distance in half-duplex last point: the power. when we have a machine under windowsXP, it is imperative never to use the power via usb, for a simple reason is that in case of failure on the USB port of the pc, it becomes impossible to repair (no more mother board, and no drivers for XP on new machines) Here is a summary, it is necessary to develop these different points in the detail, according to your needs in terms of performance, reliability and duration |
||||
Grogster![]() Admin Group Joined: 31/12/2012 Location: New ZealandPosts: 9750 |
Yes, any terminal program should work. My personal favourite is Rob's GFXterm which is small, fast and simple. You may already have GFXterm. If not, you can find it in the 'Fruit Of The Shed' pages. EDIT: Here is a link to GFXterm.... Smoke makes things work. When the smoke gets out, it stops! |
||||
| Boppa Guru Joined: 08/11/2016 Location: AustraliaPosts: 816 |
You can still find motherboards that support XP (industrial nano's) but they are rather $$$ for the power they have... I used a powered hub from the PC these days for all my stuff, it saves a lot of grief both in the usb current capacity (a lot of the older machines were current limited to 500mA mostly) which gives rise to all sorts of issues- even something as charging my tablet was an issue on the old p3 dell I was using previously to this one, it would take 8hrs+ to charge if the tablet was turned off, if it was on, it actually went flat after a day or so even tho it was plugged in and 'charging'- the usb port was supplying less than the tablet actually consumed and it would run flat.... |
||||
| Andrew_G Guru Joined: 18/10/2016 Location: AustraliaPosts: 872 |
Hi all, yes I am very wary about connections to my aged XP machine (too much smoke has escaped already - the on-board USBs no longer work). I now use those on the docking station and a USB hub. It is an 11 year old laptop and has been on a yacht for 9 months and in many aircraft - so it is a wonder it is still working. The USB-HC12 appeals to me but I am also going to try a connection to my DB9 serial port (on both the PC and its docking station). Anyone else doing something similar?? Cheers, Andrew |
||||
bigmik![]() Guru Joined: 20/06/2011 Location: AustraliaPosts: 2971 |
Is this your Yacht Andrew?? ![]() Regards, Mick Mick's uMite Stuff can be found >>> HERE (Kindly hosted by Dontronics) <<< |
||||
| Boppa Guru Joined: 08/11/2016 Location: AustraliaPosts: 816 |
I dont know why I get such a good run with Dells, my lappy is an elderly dell, used to run XP, now ubuntu, I like it because it has a dock and has real serial and parallel ports (which some of my stuff still uses) altho its battery is next to useless these days, down to 24 mins according to the meter, and thats being generous... Just long enough to get from dock to dock lol Its been dragged around the country in the cabin of a truck and 4x4, been through the windscreen of the truck in an accident, and apart from needing an external keyboard 9C and P dont work anymore) is still managing to run In that time been through at least 5 other brand laptops, all of which died quite quickly, so the old dell gets dragged out 'one more time' |
||||
| Andrew_G Guru Joined: 18/10/2016 Location: AustraliaPosts: 872 |
Hi all, So far good progress - and no smoke. I am reading the HC-12 input (from 5 devices for now) on the MM's Com2 at 2400 and immediately "Print"ing it to Com1 (at 9600) - using the "INV" option on the Open statement. Its all on breadboard but a DB9 cable connects to my PC's real serial port (it's Com1) with the MM's Gnd to the serial pin 5 and the MM's pin 21 to serial pin 2 (pin 3, TX, is NOT connected). The MM is powered from a USB connection to the PC - with MMEdit allowing me to edit the MM program and see the Console chat output. I have knocked up simple code on the PC (using QB64) to read and display the data being read on its Com1. It all appears to be working. All I need to do now is use QB64's PC graphics capability and I should be able to match the MM's 2.8" LCD display on my PC. I'll document it better in due course. Many thanks to those who lead me to believe it would be so easy. Cheers, Andrew PS: Boppa yes it is a Dell laptop 2016 model. Its on its "subsequent" battery and it needs to be connected to 240V to work. |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |