Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 06:43 22 May 2024 Privacy Policy
Jump to

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 : Serial comms on picomite

Author Message
Gbbickerton
Newbie

Joined: 22/06/2022
Location: United Kingdom
Posts: 11
Posted: 02:57pm 02 Feb 2024
Copy link to clipboard 
Print this post

I cannot get serial comms to work on the picomite, the picomite is set up on a pico res touch from waveshare, I am sending serial data from a small picaxe board that sends text at 1200 baud this is working because I can receive the text via a ttl to usb converter on the MM edit terminal, I am using this code.
Currently the picomite is in a breadboard for trouble shooting.


do
SETPIN GP5, GP4, COM2 '
OPEN "COM2:1200" AS #5 '
dat$ = INPUT$(1, #5) '
print "data"
print dat$
print loc(#5)
CLOSE #5 ' close the serial port
pause 100
loop


loc(#5) returns 0, so no data in the buffer.
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 3595
Posted: 03:04pm 02 Feb 2024
Copy link to clipboard 
Print this post

Hi Gbbickterton,'

When you open a serial port, it starts with a clean RX and TX buffer.
You program
Do
opens the serial port
Then it checks for data
Then closes it
Then waits 100ms
loop

There is very little chance a valid character is received in the microseconds.
I think your program should

open the port.

Do
check content of buffers
pause
Loop

close the port


Volhout
Edited 2024-02-03 01:07 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Gbbickerton
Newbie

Joined: 22/06/2022
Location: United Kingdom
Posts: 11
Posted: 03:49pm 02 Feb 2024
Copy link to clipboard 
Print this post

That sorted it, thank you
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3027
Posted: 04:01pm 02 Feb 2024
Copy link to clipboard 
Print this post

Welcome to the forum.

MMBasic has excellent serial communications handling. Depending on circumstances, you'd probably do best with something like this (untested):

SETPIN GP5, GP4, COM2 '
OPEN "COM2:1200" AS #5 '

do
 Do
   'HERE you want to put any code which is needed between receipt of characters, e.g.,
   if dat$ <> "" then
'     your code
     dat$=""
   endif
 Loop While Loc(#1)=0
 Pause 100 ' let characters arrive on COM1 (approx 10 per 100ms--increase as needed)
 dat$ = INPUT$(255, #5) 'get up to 255 characters
loop

PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3682
Posted: 05:37pm 02 Feb 2024
Copy link to clipboard 
Print this post

The LOC(#1) should be LOC(#5), didn't spot anything else - but untested.

John
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3027
Posted: 06:46pm 02 Feb 2024
Copy link to clipboard 
Print this post

  JohnS said  The LOC(#1) should be LOC(#5), didn't spot anything else - but untested.


Thanks--cut and paste error (plus lack of proofreading).
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9088
Posted: 10:17pm 03 Feb 2024
Copy link to clipboard 
Print this post

The COM port buffers are a thing of beauty, and I use them often as a fully automatic message queue, which can receive messages in the background, and your code just has to check the buffer as part of the main loop, and act if there is anything there to process.  They are BEAUTIFUL to have.
Smoke makes things work. When the smoke gets out, it stops!
 
Gbbickerton
Newbie

Joined: 22/06/2022
Location: United Kingdom
Posts: 11
Posted: 06:03pm 09 Feb 2024
Copy link to clipboard 
Print this post

Thanks for the help, my project is a DIY turbo trainer it uses a home made axial flux generator driving 2 mini moto electric motor bike motors with fans. A picaxe reads the current and voltage and sends the data via 433mhz units to a picomite with waveshare display. The data is in the form of UUUUUUUUUUYSM preamble these letters have equal mark space ratio which sets up the bit slicer, when YSM is  detected the next 6 bytes are the voltage current and checksum.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3027
Posted: 07:49pm 09 Feb 2024
Copy link to clipboard 
Print this post

Thanks for the explanation and the photo. Looks like heavy metal (at least for a picaxe). How are you determining the current?

"Turbo trainer"--sorry for my ignorance, but trainer for what, if you don't mind?
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Gbbickerton
Newbie

Joined: 22/06/2022
Location: United Kingdom
Posts: 11
Posted: 05:40pm 19 Apr 2024
Copy link to clipboard 
Print this post

A turbo trainer is for putting your bike on to provide resistance to pedal against while going nowhere, useful in the winter when its a bit chilly outside.
The generator and motors provide a really nice feeling load.
The two white blocks are wire wound resistors the voltage across is measured to get the current, the losses are taken into account when calculating the wattage output by the rider.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3027
Posted: 07:21pm 19 Apr 2024
Copy link to clipboard 
Print this post

Ok, thanks.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
PhenixRising
Guru

Joined: 07/11/2023
Location: United Kingdom
Posts: 334
Posted: 12:44am 20 Apr 2024
Copy link to clipboard 
Print this post

  Gbbickerton said  A turbo trainer is for putting your bike on to provide resistance to pedal against while going nowhere, useful in the winter when its a bit chilly outside.
The generator and motors provide a really nice feeling load.
The two white blocks are wire wound resistors the voltage across is measured to get the current, the losses are taken into account when calculating the wattage output by the rider.


Business Op. Have them tied in to the grid. Also have convicts and climate-alarmists pedal them  
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 5776
Posted: 07:26am 20 Apr 2024
Copy link to clipboard 
Print this post

Surely the next step is to feed an inverter/regulator and charge a battery bank. That powers the mini fridge and a small TV so that after exercise one can slonk on the sofa and watch the match with a cold can or three?  :)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024