Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 01:26 27 Nov 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 : PicoMite Pulse counter

     Page 2 of 3    
Author Message
Dinosaur

Guru

Joined: 12/08/2011
Location: Australia
Posts: 311
Posted: 07:25pm 11 Nov 2023
Copy link to clipboard 
Print this post

Hi All

  Quote  Not a Linux guy but was wondering if there was a way to simply power-up-and-go or is there a bunch of setup involved?


If you want to use Linux on a Rpi, I would suggest Debian.But remember, everything happens slower on Rpi Zero W2, so patience. Have not used any of the more powerfull Rpi's so can't comment.

If you want to learn but also use Linux on a PC, then my pick would be Linux Mint.

Installing Debian on the Pi is as simple as writing an image to a micro SD and from then on
it is using the GUI tools provided.
Once you got it working with the apps you want,then keep copying the SD card so that when
you stuff it up, just re-write the SD.

If you want to use FreeBasic, then join the Forum and you will get all the help you need
without any of the bitching / attitude that goes on, on some forums.

Once you have FreeBasic installed, then you will forget all about the fact that you are using Linux.

I Started on the Z80, progressed to Dos, Windows and finally Linux.
Learned QuickBasic and then FreeBasic, hated C with a passion so never ventured there.
Edited 2023-11-12 05:27 by Dinosaur
Regards
Hervey Bay Qld.
 
Dinosaur

Guru

Joined: 12/08/2011
Location: Australia
Posts: 311
Posted: 06:03am 27 Nov 2023
Copy link to clipboard 
Print this post

Hi All

Finally have the Pico connected to a test rig that is putting out 70Khz into GP18.

Steps I took to get the count showing:
From the prompt: >
1:  OPTION COUNT GP18,GP19,GP20,GP22
OPTION LIST shows correct.
2:  SETPIN GP18,CIN

Pico hangs, Ctrl C won't break out of it.

3:  SETPIN GP18,FIN

Also tried SETPIN GP18,FIN,100

Ditto Pico hangs.

4:  SETPIN GP18,DIN
   Print PIN(GP18) randomly shows 0 or 1 (as expected)

What am I doing wrong ?
Edited 2023-11-27 16:04 by Dinosaur
Regards
Hervey Bay Qld.
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4237
Posted: 06:11am 27 Nov 2023
Copy link to clipboard 
Print this post

Hi Dinosaur,

Tell us the result of OPTION LIST
Tell us what MMBasic version

Volhout
PicomiteVGA PETSCII ROBOTS
 
Dinosaur

Guru

Joined: 12/08/2011
Location: Australia
Posts: 311
Posted: 06:14am 27 Nov 2023
Copy link to clipboard 
Print this post

Hi Volhout

WebMite MMBasic Version 5.07.08RC21
OPTION SYSTEM I2C GP8,GP9
OPTION AUTORUN  ON
OPTION WIFI Rpi-Hotspot, ********, PICOE6614C311B4
OPTION COUNT GP18,GP19,GP20,GP22

Same with
WebMite MMBasic Version 5.07.08RC17
OPTION SYSTEM I2C GP8,GP9
OPTION WIFI Rpi-Hotspot, ********, PICOE6614C311B4
OPTION COUNT GP18,GP19,GP20,GP22
Edited 2023-11-27 16:26 by Dinosaur
Regards
Hervey Bay Qld.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6098
Posted: 06:38am 27 Nov 2023
Copy link to clipboard 
Print this post

Works OK here on RC21
'
SETPIN GP18, CIN
PRINT PIN(GP18)
PAUSE 3000
PRINT PIN(GP18)



You are running it in a program, not on the command line?
VK7JH
MMedit   MMBasic Help
 
Dinosaur

Guru

Joined: 12/08/2011
Location: Australia
Posts: 311
Posted: 06:50am 27 Nov 2023
Copy link to clipboard 
Print this post

Hi All

No the last results were from the command line.
But the reason for that was the example given to me on a previous post.

However, it did the same inside my program.
Regards
Hervey Bay Qld.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6098
Posted: 06:59am 27 Nov 2023
Copy link to clipboard 
Print this post

It should work from the command line (mine does)
It is much easier to replicate your actions if you give a short program that shows the error.

Try a much slower source frequency as a test.

Jim
VK7JH
MMedit   MMBasic Help
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4237
Posted: 07:03am 27 Nov 2023
Copy link to clipboard 
Print this post

Works perfect here.

WebMite MMBasic Version 5.07.08RC17
OPTION SYSTEM I2C GP8,GP9
OPTION COLOURCODE ON
OPTION WIFI ziggo279823, **********, PICOE6614C311B3
OPTION COUNT GP18,GP19,GP20,GP22


Running this program

SetPin gp18,cin
SetPin gp0,pwm

PWM 0,5000,50

Do
Pause 1000
Print Pin(gp18)
Loop



Volhout
Edited 2023-11-27 17:24 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Dinosaur

Guru

Joined: 12/08/2011
Location: Australia
Posts: 311
Posted: 07:09am 27 Nov 2023
Copy link to clipboard 
Print this post

Thanks for that

Will have to reroute my 22 to 21

Beer O'Clock at the moment.
Regards
Hervey Bay Qld.
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4237
Posted: 07:30am 27 Nov 2023
Copy link to clipboard 
Print this post

Dino

In my above example I use 18,19,20 and 22.
The test program uses gp18 to count, gp0 to generate a pulse (wire from gp0 to gp18).
But I tried your exact setup with pin 22, and that works also.

So you can use 18,19,20,22. No need to change.
I did not know that. Never to old to learn...

Volhout

P.S. you talked about "hanging". Could this be related to the WIFI connection reconnecting due to poor reception. ????
PicomiteVGA PETSCII ROBOTS
 
Dinosaur

Guru

Joined: 12/08/2011
Location: Australia
Posts: 311
Posted: 07:36am 27 Nov 2023
Copy link to clipboard 
Print this post

Hi All

No, because I placed the snippet of code before the start of my main routines
and placed an END after it, so once the SETPIN command was executed, the program
should have quit back to the command prompt.
But it didn't, and even MMC would not quit the connection.

And the wifi is HOtspot 1 meter away from a Rpi Zero.
Edited 2023-11-27 17:37 by Dinosaur
Regards
Hervey Bay Qld.
 
Dinosaur

Guru

Joined: 12/08/2011
Location: Australia
Posts: 311
Posted: 07:55am 27 Nov 2023
Copy link to clipboard 
Print this post

Hi All

Took Tassie Jim's suggestion and slowed it down to 1.4khz and it works correctly.
Now I am worried that I may not get the bandwidth I need.

Was hoping for 20Khz, so tomorrow will try to shuffle timing caps to get that, and see if it will work ?

Thanks for the help.
Regards
Hervey Bay Qld.
 
Dinosaur

Guru

Joined: 12/08/2011
Location: Australia
Posts: 311
Posted: 09:21am 27 Nov 2023
Copy link to clipboard 
Print this post

Hi All

Managed to get 15kHz with the capacitors on hand, but then hooked up pwm GP0 and saw good results even at 70kHz.
For my system to hang at 70Khz, may mean that the waveform is very poor.
So will hang a cro onto it and see.It also quite likely that the duty cycle is way off.

But at least it has shown capable of measuring at those speeds.
Also the stability at 20Khz is within 2 or 3.
Yet my system at 15Khz was varying by much more.

In any case , many thanks for your patience and help.
Hopefully others will read and use the experience.
Regards
Hervey Bay Qld.
 
Dinosaur

Guru

Joined: 12/08/2011
Location: Australia
Posts: 311
Posted: 10:32am 29 Nov 2023
Copy link to clipboard 
Print this post

Hi All

Experiencing hanging  that I can't Ctrl C out of and can't work out why.
Have simplified the code to try and isolate it.
It lasts for hours without updating the terminal.

At the moment I am using pwm at 30khz to drive GP18 counter.
GP18is set as CIN.
Interupt is set at 60,000
SETTICK 60000,CountInt

and goes to the following routine.

sub CountInt
   Count     = Pin(GP18)
   Pin(GP18) = 0
   Sample = Sample + 1      'Is Sample += 1 allowed ??
   Print "Count = ";Count / 60,Sample,"***"
   StepNbr = 4
End Sub

The code where it goes after the Interupt routine:
is simplified to:

   If MM.INFO(Wifi Status) > 0 Then WifiConnect
   WEB MQTT PUBLISH "AmpHr",Str$(TxValue) , 1 ,1
   WEB MQTT CLOSE
 
Then a 50mSec pause and go and wait for interrupt again.

I am opening and closing the Wifi (MQTT) connection every minute.

If I run and wait for the Interupt and DON'T call the Wifi routines above, then it seems to last.(Need to test it for 24 hrs)

What is the consensus of opinion as to leaving the Wifi connection open 24/7 ? and could switching it on/off so frequently cause problems.
I have purposely scheduled the Wifi routines after the Interrupt and they only last 5 seconds.
Regards
Hervey Bay Qld.
 
Dinosaur

Guru

Joined: 12/08/2011
Location: Australia
Posts: 311
Posted: 12:51am 27 Dec 2023
Copy link to clipboard 
Print this post

Hi All

Just an update for anyone using the Pico for pulse counting.
The chart below shows that on every interrupt (60 secs) the count gets corrupted.
So have to edit the reading so that this reading is ignored.
Otherwise getting 4mA stability with no Input on the ACHS7123 and connected to an AD654.

Regards
Hervey Bay Qld.
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3802
Posted: 08:34am 27 Dec 2023
Copy link to clipboard 
Print this post

If you can make the shortest simple version showing it then you've a chance either your or the Pico bug will get attention & be fixed.

John
 
Dinosaur

Guru

Joined: 12/08/2011
Location: Australia
Posts: 311
Posted: 09:24am 27 Dec 2023
Copy link to clipboard 
Print this post

Hi All

Thanks for the response JohnS.

I wasn't really looking for a fix, merely keeping anyone interested that this issue can bite you in the *ss.

Don't know if the count interrupt is being "interrupted" by performing a Wifi transmission (I am getting less pulses),
OR there is a slight power dip as a result of the Wifi being used every 60 seconds.

Solved it by;

Sub Count_Int                    '1 Minute Interupt handler.
   Count30   = Pin(GP18)        'pulse count from 30Amp Shunt
   Pin(GP18) = 0
   SetTick Pause,Count_Int,1
   SkipCnt = 1                  'Let TaskScan know we have Paused
   StartTime5 = (Timer - CalTime)


Then When the Wifi is completed;
   If SkipCnt = 1 Then
     If (Timer - CalTime) - StartTime5 > 35 Then
         Pin(GP18) = 0                                     'zero to re-accumulate
         SetTick 60000,Count_Int,1
         SkipCnt = 0
     EndIf
   EndIf
The only thing I don't like is that I am going to have to assume that the missing count from the 35mSec will be a linear extrapolation of the end of the previous Minute and the start of the next Minute.
Haven't had any dips for an hour, but will get them if I drop the pause below 30mSec.
Regards
Hervey Bay Qld.
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3802
Posted: 10:00am 27 Dec 2023
Copy link to clipboard 
Print this post

It may be a non-issue or one that can be fixed but only if there's a (short, self-contained) example to reproduce it.

John
 
Dinosaur

Guru

Joined: 12/08/2011
Location: Australia
Posts: 311
Posted: 10:05am 27 Dec 2023
Copy link to clipboard 
Print this post

Hi All
  Quote   (short, self-contained) example to reproduce it.

Will work on that.
Regards
Hervey Bay Qld.
 
Dinosaur

Guru

Joined: 12/08/2011
Location: Australia
Posts: 311
Posted: 07:48pm 27 Dec 2023
Copy link to clipboard 
Print this post

Hi All

Found the issue.
Ran tests all night and when I looked at the data, discovered that instead of getting a drop in counts every minute (during Wifi).
I now have a drop only every Hour.

           If Delay4 = 1 Then                        '1 Hour's time is up.(10 year life)
               VAR Save BattCharge                   'Saving for possible reboot
               StartTime4 = mSec :Delay4 = 0
               If PFlag = 1 Then Print "5: Var BattCharge saved"
           EndIf
The AD654 is running on 10vdc, so not the cause, but the Volt 2 Freq converter is on 5vdc.
When the Pico draws more current (Wifi, Var Save) there is a slight voltage drop during that minute.
It lasts for about 28mSec. Will see about adding a cap to see if that solves the problem.
Haven't measured actual current drawn yet, but this PS should easily handle it.


It was always going to be time consuming to emulate this in simple code example, as whomever was going to test would need to have a Wifi link as well.
Regards
Hervey Bay Qld.
 
     Page 2 of 3    
Print this page
© JAQ Software 2024