Menu
JAQForum Ver 19.10.27

Forum Index : Microcontroller and PC projects : Serial comms on picomite

Posted: 02:57pm
02 Feb 2024
Copy link to clipboard
Gbbickerton
Newbie

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.
 
Posted: 03:04pm
02 Feb 2024
Copy link to clipboard
Volhout
Guru

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
 
Posted: 03:49pm
02 Feb 2024
Copy link to clipboard
Gbbickerton
Newbie

That sorted it, thank you
 
Posted: 04:01pm
02 Feb 2024
Copy link to clipboard
lizby
Guru

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
 
Posted: 05:37pm
02 Feb 2024
Copy link to clipboard
JohnS
Guru

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

John
 
Posted: 06:46pm
02 Feb 2024
Copy link to clipboard
lizby
Guru

  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).
 
Posted: 10:17pm
03 Feb 2024
Copy link to clipboard
Grogster
Admin Group


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.
 
Posted: 06:03pm
09 Feb 2024
Copy link to clipboard
Gbbickerton
Newbie

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.
 
Posted: 07:49pm
09 Feb 2024
Copy link to clipboard
lizby
Guru

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?
 
Posted: 05:40pm
19 Apr 2024
Copy link to clipboard
Gbbickerton
Newbie

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.
 
Posted: 07:21pm
19 Apr 2024
Copy link to clipboard
lizby
Guru

Ok, thanks.
 
Posted: 12:44am
20 Apr 2024
Copy link to clipboard
PhenixRising
Guru

  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  
 
Posted: 07:26am
20 Apr 2024
Copy link to clipboard
Mixtel90
Guru


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?  :)
 


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

© JAQ Software 2024