i dont see why it wouldnt be safe its a power block not direct to the mains lol, used a sacrificial USB cable, stripped the wires ~ 200mm from the socket and identified the + & - and used them to supply power. where am i going wrong lol? regardless its still performing the same either way, i have not added a 4.7K resistor across + and DATA pins of the 3144, enabled pin 2 as PULLUP...
well i took a few steps back with guidance from the following link....
working one step at a time, as a basic magnetic switch to light external LED using arduino as power supply - check, works fine.
then the same situation but to light the onboard LED when magnet detected - check.
next step, simple tacho - nothing on the serial monitor or plotter, litrally no reaction
this is the simple tacho code...
const int hallPin = 2;
const int maxCnt = 100;
void setup() {
Serial.begin(9600);
pinMode(hallPin, INPUT);
}
void loop() {
unsigned long start = micros();
int old = 1;
int cnt = 0;
while (cnt < maxCnt) {
int val = digitalRead(hallPin);
if (!val && val != old) cnt++;
old = val;
}
float seconds = (micros() - start) / 1000000.0;
float rpm = cnt / seconds * 60.0;
Serial.print("rpm: ");
Serial.println(rpm);
}
on the plus side, going back and working through it like this is giving me a chance to brake down the code and actually understand (to some degree) whats happening - what i should have done anyway lol.
and the ground of the sensor goes to arduino ground VIA the breadboard, is it worth trying it direct to arduino? in my head if it worked before as a switch, it shouldnt be any different :/?
You can't imagine how often poor powering comes up here...
This can be a mistake! You must disable interrupts on the line before reading those values, and enable interrupt after it. As You have a delay of 500 ms an interrupt can occur at the same time as the code is reading those 4 + 4 byte long variables.
also would this make a difference to the fact that my serial monitor/plotter is inactive? im assuming thats an issue alone and could do with sorting that out, anyone know of any reason it could be deactivated?
i read a post saying uninstalling/reinstalling the IDE helped but ive done that with no joy
also could the serial issue be more a hardware issue? i only have this one NANO to hand as im staying with family over christmas, ive got a few NANOs and a few UNOs at mine so if its possibly the issue, i may wait till the 31st when i get home lol
I would focus on the code without interrupts. The last posted tutorial is OK, and you should be able to sort out your issues using it. Your issues are not in the code.
Regarding the Serial monitor, is the baud rate set to the same as in the sketch?
Ok, so when you say my issues are not in the code do you mean its likely or possible that theres an issue with my hardware?
and yes both the sketch and serial monitor/plotter are set to 9600
Hi, well i started a fresh - brand new UNO, new A3144, new 10K resistor.
when i compile, its fine, then i go to upload, and it comes up with the following ...
Sketch uses 5440 bytes (16%) of program storage space. Maximum is 32256 bytes.
Global variables use 338 bytes (16%) of dynamic memory, leaving 1710 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\joshh\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\joshh\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM5" -b115200 -D "-Uflash:w:C:\Users\joshh\AppData\Local\arduino\sketches\FA815C52EBBB4378C1D4DA8A8A844449/RPM_intr_nick_gammon_1.ino.hex:i"
avrdude: Version 6.3-20190619
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "C:\Users\joshh\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"
Using Port : COM5
Using Programmer : arduino
Overriding Baud Rate : 115200
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : Arduino
Description : Arduino
Hardware Version: 3
Firmware Version: 4.4
Vtarget : 0.3 V
Varef : 0.3 V
Oscillator : 28.800 kHz
SCK period : 3.3 us
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.00s
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "C:\Users\joshh\AppData\Local\arduino\sketches\FA815C52EBBB4378C1D4DA8A8A844449/RPM_intr_nick_gammon_1.ino.hex"
avrdude: writing flash (5440 bytes):
Writing | ################################################## | 100% 0.73s
avrdude: 5440 bytes of flash written
avrdude done. Thank you.
i do not understand why its overriding the baude rate i check that its set to 9600, then after upload it says its been overridden, im very far from an expert (quite far from a beginner haha) - i cannot let this defeat me lol but its getting frustrating now.
i have tried uninstalling/reinstalling the IDE and it was no different, please someone help lol
many thanks,
josh.
You have posted the results of a successful upload of the code to your Uno. One more thing you can do to confirm is to check the pull down box "Verify code after upload" in the IDE with File> Preferences.
The baud rate for the sketch upload is different from the baud rate used in the sketch for communication with the Serial Monitor. I think this is the sketch you loaded with the posted output.
The posted code wants the monitor to be set at 115200.
well when i plug the UNO in, it has been displaying what should be 'niq_ro' but with segments missing (if i restart the UNO, it doesnt seem to replicate the same each time, there will be less or more segments each time ) then the the display will sometimes display a few random numbers then go blank until restarted.
the display is the last thing that i havent replaced to see if its the issue, could it be that ? i cant imagine thats it but everything else has been swapped and the issue is still the same, starting to drive me a bit mad now lol.
Hi, yes basically the hall sensor is being read and the serial monitor shows largly the correct rpm, the only thing is every few readings it shows a massively high RPM, heres the serial output...
other than that yes the only issue is displaying it - but like i said ive tried 2 brand new 7seg/8digit displays (MAX7219) with the same results so assuming the problem must be with the code ?
I just ran the LedControl example - intead of showing 'arduino' one letter at a time on digit 0, it will do the first couple of letters then the next on the next digit, or repeat letters - and the numbers afterward were almost entirely random
Good news! i just wired a 5V 1A power supply to the MAX7219 board, with the GND also going to the arduino and it worked it does still jump up to ridiculus numbers from time to time but still a massive improvement thanks ever so much for your help so far, any ideas about why it would jump like that?