Warning: mysqli::__construct(): (HY000/1203): User howardkn already has more than 'max_user_connections' active connections in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\includes\artfuncs.php on line 21
Failed to connect to MySQL: (1203) User howardkn already has more than 'max_user_connections' active connections
Warning: mysqli::query(): Couldn't fetch mysqli in D:\Inetpub\vhosts\howardknight.net\al.howardknight.net\index.php on line 66
Article <utei2u$1fe57$1@dont-email.me>
Deutsch   English   Français   Italiano  
<utei2u$1fe57$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: "Jim Wilkins" <muratlanne@gmail.com>
Newsgroups: rec.crafts.metalworking
Subject: Re: Arduino + MCP9600 + thermocouple help needed
Date: Wed, 20 Mar 2024 07:41:52 -0400
Organization: A noiseless patient Spider
Lines: 134
Message-ID: <utei2u$1fe57$1@dont-email.me>
References: <m1v85j8ast.fsf@void.com> <utai8d$e7ee$1@dont-email.me> <utanb3$f5i9$1@dont-email.me> <m1ttl3qahq.fsf@void.com> <utb2r3$l04f$1@dont-email.me> <m134smjy0e.fsf@void.com> <ute49n$1ci6f$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain;
	format=flowed;
	charset="iso-8859-1";
	reply-type=original
Content-Transfer-Encoding: 7bit
Injection-Date: Wed, 20 Mar 2024 11:42:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e1859308e4ab75aac775207e24390375";
	logging-data="1554599"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18C7rYGK3ae1aFj7VXRRfwuwR39SRg6t/8="
Cancel-Lock: sha1:mK0hNgqnALsy42q3Rgfljsv8fMI=
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Windows Live Mail 16.4.3505.912
X-Priority: 3
X-Antivirus: AVG (VPS 240301-2, 3/1/2024), Outbound message
Importance: Normal
X-Antivirus-Status: Clean
X-MimeOLE: Produced By Microsoft MimeOLE V16.4.3505.912
In-Reply-To: <ute49n$1ci6f$1@dont-email.me>
Bytes: 9091
X-Original-Lines: 262

"James Waldby"  wrote in message news:ute49n$1ci6f$1@dont-email.me...

Richard Smith <null@void.com> wrote:
> "Jim Wilkins" <muratlanne@gmail.com> writes:
>> "Richard Smith"  wrote in message news:m1ttl3qahq.fsf@void.com...
>>
>>> "Second picture is where commented-out "pinMode(2,
>>> INPUT_PULLUP);". Initially LED lighting randomly when button not
>>> pressed. Then added in the circuit the "pull-up" resistor connected to
>>> on-board supply voltage and the circuit behaved like the first
>>> circuit."

The webpage pictures and your problem descriptions aren't clear enough
or specific enough for definitive help.  Explicit wiring diagrams and
complete code listings are needed, as well as context like Arduino
IDE version number.  <https://arduino.stackexchange.com> may be of
help if you can fully explain what you wired up and give a
minimum-working-example for the problem,

I suggest that when getting started, you first navigate to the Blink
sketch (run Arduino, then File / Examples / Basics / Blink) and
compile it and download it.  Then, to verify you are able to make and
install program changes, copy it to a directory of your own with a new
name, eg Blink2, and try a few simple changes, like substituting 13 in
place of LED_BUILTIN, or 400 in place of 1000, etc. and download
again.  If you want to try an external LED, connect it to some other
IO pin (not D13) with eg a 2K resistor, put that IO number into your
Blink2, test it, etc.

Then, if you are working with a program like DigitalInputPullup,
connect a switch between an IO pin and Gnd, say D2 and ground, per
..png-image schematics in examples/02.Digital/DigitalInputPullup .
When you download the program to the Uno and it starts running,
setup() will be called, which will set up serial IO and pinModes for
D2 and D13.  The pinMode(2, INPUT_PULLUP) statement places D2 into
input mode with a pullup resistor to V+ (say 5V).  That is, if D2 is
in the INPUT_PULLUP state, an internal resistor like 35K ohms (RPU min
20K, max 50K per spec sheet) is connected between V+ and D2, which
means that if you leave D2 open, D2 will sit at V+; or if you connect
D2 to ground, after transients settle (~1us) D2 will sit at 0V, and
some number of uA, eg 5/35000 A ~ 143 uA, will flow through the pullup
resistor.  You can measure that current by hooking an ammeter between
the pin and ground if you want to calculate pullup resistance.  If the
current's really high or is zero the pin's not in INPUT_PULLUP mode.
If you have an external pullup and turn on INPUT_PULLUP, the effective
pullup resistance is the two resistors in parallel.  If your external
resistor is a pulldown (connected to Gnd instead of V+) the open-pin
voltage [open aside from pull resistors] will be that of a resistor
divider, instead of 0 or V+.

Re the I2C problem with your MCP9600 breakout board - Again, wiring
diagrams and code listings are needed for diagnosis.  One comment: You
could write an if statement to try both addresses, 0x66 and 0x67,
mentioned in the Pimoroni page, or a loop to try the whole range
0x60-0x67, proceeding ahead when a ready-test succeeds.  Or, for
simpler programming you could make a program with one address,
download and test it, then change it for each possible address until
successful.  The I2C fails I've seen were due to wrong addresses,
miswiring, bad chips, or in one case wires longer than a few feet.

>> Unconnected inputs are sensitive antennas that pick up secret messages
>> from space, or noise from fluorescent lights and radio/TV
>> transmitters. Some even float to a middle level where they partly turn
>> on both the input high and input low circuits, causing oscillation or
>> higher power consumption. They are all best made high or low if not
>> used. [...]

Setting an open IO to low or high output like that is one approach,
but on the Arduino Uno a simpler / less risky approach is to set
pinMode to INPUT_PULLUP.  Note, ATmega328P microcontroller chip
hardware as on an Uno sets all IO pins to INPUT during Reset, but boot
firmware changes the modes of some pins like D0, D1, D13 as per eg
<https://forum.arduino.cc/t/behavior-of-pins-during-reset-state/640285/12>

> It is a bit of a thought that I would need an oscilloscope to
> proceed much further.

One can do a lot with indicator LEDs attached to several outputs.  You
can connect a resistor in series with an LED between an IO pin and
ground or 5V.  Eg, a 3.5V LED with a 1.5K resistor will draw 1 mA,
either when the pin is low if series is between 5V and pin, or when
the pin is high if series is between Gnd and pin. ( 0.001 A =
(5V-3.5V)/1500 ohms.)  Or, because modern LEDs light up ok (visible
but not annoyingly bright) with a few microamps, you can connect an
LED between an IO pin and Gnd; turn it on with perhaps 43 uA, ie
(5V-3.5V)/35000 ohms, when you set pinMode to INPUT_PULLUP; turn it
off by setting pinMode to INPUT.  Note, outputting debug data via the
serial port also is easy to do with Arduino.

If you are uncertain how much electronics work you'll do, or have to
really economize, an item like <https://www.amazon.com/dp/B0C6XPVLPZ>
($37) would get you at least basic scope function, making it possible
to see switch bounce, PWM sequences, and other low frequency stuff.
For a hundred or two more, you can get a 50MHz 2 channel scope like
previously mentioned, a big step up.  If you're into micros for the
long term, go ahead and get a medium cost 4 channel 100MHz or 200MHz
scope, somewhere between $300 and $800.  Scopes in that range often
have an input to accept data from optional add-on logic analyzer
modules, adding 8 or more 0-1 inputs, and often have builtin protocol
analyzers.  Eg, besides displaying an I2C waveform they show its data
content as text on the screen.

> I have seen videos of them used to diagnose even what is happening
> when you push a push-button - all sorts of noise!  With the
> oscilloscope showing very clearly.

It's mostly switch bounce, not noise.  On some switches bounce will be
over within just a few milliseconds (ms), on others it can be dozens
of ms.  With search terms = arduino debounce, you can find code
examples plus simple switch or switch+resistor circuits, and may also
see pages like below with more-complex Schmitt trigger hardware
debounce, or with low-pass filters, which in some cases are truely
awful, amazingly bad.  Following link explains bounce problem and
shows hardware and software debouncing with detailed code notes.
<https://www.circuitbasics.com/how-to-use-switch-debouncing-on-the-arduino/>

--------------------------
Thanks, I'm glad someone whose Arduino experience is less archaic than mine 
has jumped in. I think in hardware terms, voltage and current,  and should 
have clarified that INPUT_PULLUP is sufficient to make the pin high.

The $23 one-channel DSO211 oscilloscope I have doesn't seem available and 
wouldn't capture both I2C signals so I didn't suggest it. I bought it for 
signals whose return can't be grounded.

IIRC the Arduino needed a separate terminal to talk to the user, the IDE 
didn't provide that function. Does it now?

The simplest switch debouncer I've seen and used is a spare buffer or 
noninverting gate(s) with a feedback resistor from output to input that 
makes it retain its logic level until the switch on its input yanks it to 
the other one. The switch needs to be double throw, connected to both power 
and ground, the resistor limits gate output current. In the days of 
hardwired logic there were almost always spare gates available.