Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:21 02 Jul 2025 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 : Help with Raspberry pico MMBasic Tachometer

Author Message
vhofst

Newbie

Joined: 29/01/2024
Location: Chile
Posts: 4
Posted: 08:36pm 27 Jun 2025
Copy link to clipboard 
Print this post

Hello everyone !!!

Some time ago I have had a small problem, which is not being able to measure rpm.
I use a CPU fan as a reference to be able to measure, but the readings always come out at 0.

attached the reference image.

I set OPTION COUNT gp6,gp7,gp8,gp9

on SETPIN i try PIN,CIN, and FIN.

and the code i use the same in page 46 of last MMBASIC manual.






In advance, thank you very much for your help.
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3348
Posted: 08:45pm 27 Jun 2025
Copy link to clipboard 
Print this post

Try outputting a PWM signal to a pin connected to pin 3 on your connector. If your count then works, that tells you that there's a problem with the wiring to your actual device. If it doesn't work, there's a problem with your code.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 5023
Posted: 08:56pm 27 Jun 2025
Copy link to clipboard 
Print this post

Typically, a 3 wire fan has power, ground, and pwm control for fan speed. Fans with a 4 wire connection have a tacho output and pwm.

Are you sure your 3 wire fan has tacho out? Note that a tacho output needs a pullup resistor (10k to 3.3v when used with a pico) to work.

Volhout
Edited 2025-06-28 07:01 by Volhout
PicomiteVGA PETSCII ROBOTS
 
vhofst

Newbie

Joined: 29/01/2024
Location: Chile
Posts: 4
Posted: 01:18am 01 Jul 2025
Copy link to clipboard 
Print this post

The green wire of the CPU fan gives the signal to measure RPM, the problem is that not work, this wire have more than 3.3V and Ground(when sense).

I used another sensor through an optocoupler, where pin(gp7) has pullup (10k to 3.3V) and the optocoupler connects to ground. This scheme did work.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2579
Posted: 02:24am 01 Jul 2025
Copy link to clipboard 
Print this post

First check that the Pico is reading frequency correctly, as Lizby suggested.
Put a jumper from GP2 to GP7 then enter the following at the command prompt:-
> setpin gp2, pwm : pwm 1, 1234, 50 : setpin gp7, fin : Pause 2000 : ? pin(gp7)
 1234
>
If the output is 1234 after 2 seconds then that is working. The pause is needed to allow time for the PWM to start and then to count pulses for 1 second.
Remove the jumper.

To reduce the 5V signal to 3.3V use a voltage divider. 18kΩ from fan output to GP7 and 33kΩ from GP7 to ground.

Then run the fan and try this:-
> setpin gp7,fin : do : ? pin(gp7) : Pause 1000 : loop
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025