Posts with «pwm» label

Simple Circuit Keeps Process Control Loops in Tune

Spare a moment’s pity for the process engineer, whose job it is to keep industrial automation running no matter what. These poor souls seem to be forever on call, fielding panicked requests to come to the factory floor whenever the line goes down. Day or night, weekends, vacations, whatever — when it breaks, the process engineer jumps.

The pressures of such a gig can be enormous, and seem to have weighed on [Tom Goff] enough that he spent a weekend building a junk bin analog signal generator to replace a loop calibrator that he misplaced. Two process control signaling schemes were to be supported — the 0 to 10 VDC analog signal, and the venerable 4-20 mA current loop. All that’s needed for both outputs is an Arduino and an LM358 dual op-amp, plus a few support components. The 0-10 V signal starts as a PWM output from the Arduino, with its 0-5 V average amplified by one of the op-amps set up as a non-inverting amp with a gain of 2. With a little filtering, the voltage output is pretty stable, and swings nicely through the desired range — see the video below for that.

The current loop output is only slightly more complicated. An identical circuit on a separate Arduino output generates the same 10 V max output, but a code change limits the low end of the range to 1 V. This output of the op-amp is fed through a 500-Ω trimmer pot, and the magic of Ohm’s Law results in a 4-20 mA current. The circuit lives on a piece of perf board in a small enclosure and does the job it was built for — nothing fancy needed.

And spoiler alert: [Tom] found the missing loop calibrator — after he built this, of course. Isn’t that always the way?

Hacker Driven to Build R/C Forza Controller

Generic video game console controllers have certainly gotten better and more ergonomic since the hard corners of the Atari joystick. As beautiful and engrossing as games have become, the controller is still the least engaging aspect. Why race your sweet fleet of whips with an ordinary controller when you could pretend they’re all R/C cars?

[Dave] found an affordable 4-channel R/C controller in the Bezos Barn and did just that. It took some modifications to make it work, like making a daughter board to turn the thumb grip input from a toggle button to a momentary and figuring out what to do with the three-way slider switch, but it looks like a blast to use.

The controller comes in a 6-channel version with two pots on the top. Both versions have the same enclosure and PCB, so [Dave] already had the placement molded out for him when he decided to install a pair of momentary buttons up there. These change roles based on the three-way slider position, which switches between race mode, menu mode, and extras mode.

We love the way [Dave] turned the original receiver into a USB dongle that emulates an Xbox 360 controller — he made a DIY Arduino Pro Micro with a male USB-A, stripped down the receiver board, and wired them together. There’s an entire separate blog post about that, and everything else you’d need to make your own R/C controller is on GitHub. Check out the demo and overview of the controls after the break.

[Dave] is no stranger to making game controllers — we featured his DJ Hero controller modified to play Spin Rhythm XD a few months ago.

Via r/duino

Measuring the Time is a Breeze With This Air Flow Clock

If you’ve ever had surgery, and you’re over a certain age, chances are good you’re familiar with the dreaded incentive spirometer. It’s a little plastic device with one or more columns, each of which has a plastic ball in it. The idea is to blow into the thing to float the balls, to endure that your lungs stay in good shape and reduce the chance of pneumonia. This unique air-powered clock reminds us a little of that device, without all the pain.

Like a spirometer, [Nir Tasher]’s clock has three calibrated tubes, each big enough to hold a foam ball loosely. At the bottom of each tube is a blower whose motor is under PWM control. A laser rangefinder sits below each ball and measures its height; the measurement is used by a PID loop to control the speed of each fan and thus the height of each ball. The video below shows that the balls are actually pretty steady, making the clock easy to read. It doesn’t, however, reveal what the clock sounds like; we’re going to go out on a limb here and guess that it’s pretty noisy. Still, we think it’s a fantastic way to keep time, and unique in the extreme.

[Nir]’s Air Flow clock is an early entry in the 2020 Hackaday Prize, the greatest hardware design contest on Earth. Everyone should enter something, or at least check out the cool things people are coming up with. It’s still early in the process, but there are so many neat projects already. What are you waiting for?

The HackadayPrize2020 is Sponsored by:

Tool Writes Your PWM Code for You

The good thing about computers is they do your work for you, right? If you are a programmer, that doesn’t always seem to be a true statement. [Runtimemicro] has the answer, at least if you are writing PWM code for the Arduino. Their free application lets you set a few parameters, visually see the results, and then generates code for you. You can see a video of the tool in operation, below.

According to their site, the tool works for timers 1 through 5 on an Arduino Nano, Uno, or Mega2560. The app appears to work on Windows, but it doesn’t look like it would have any trouble running under Wine on other platforms.

There are only a few inputs: the clock speed, which timer you want to use, and the mode. You also have to specify the frequency in Hz or the period in milliseconds. You can also select a few options, including if you want interrupt code generated.

Once the timer shows up in the graphical display, you can adjust some sliders to get the exact PWM duty cycle you want. Of course, you can also skip the PWM code and just use the timer interrupts for timing.

It isn’t that the timer code or PWM isn’t workable without a tool. But then again, you don’t really need an assembler or a compiler — it just makes things easier. There are a few nuances, though. If you want to dig through the generated code, you might find [Jack’s] video interesting.

Hack a Day 06 Feb 19:30

Arduino Powered Arcade Button Lighting Effects

As if you already weren’t agonizing over whether or not you should build your own arcade cabinet, add this one to the list of compelling reasons why you should dedicate an unreasonable amount of physical space to playing games you’ve probably already got emulated on your phone. [Rodrigo] writes in to show off his project to add some flair to the lighted buttons on his arcade controller. (Google Translate)

The wiring for this project is about as easy as you’d expect: the buttons connect to the digital inputs on the Arduino, and the LEDs on the digital outputs. When the Arduino code sees the button getting pressed, it brings the corresponding LED pin high and starts a fade out timer using the SoftPWM library by [Brett Hagman].

It’s worth noting that the actual USB interface is being done with a stand-alone controller, so the Arduino here is being used purely to drive the lighting effects. The more critical reader might argue that you could do both with a single microcontroller, but [Rodrigo] was in a classic “Use what you’ve got” situation, and already had a USB controller on hand.

Of course, fancy lit arcade buttons won’t do you much good without something to put them in. Luckily we’ve covered some fantastic looking arcade cabinets to get you inspired.

Hack a Day 20 Jul 21:00

Need a Thousand Extra PWM Pins?

If your Arduino runs out of I/O lines, you can always add one of the several I/O expander chips that takes a serial interface to set its several pins. Or perhaps you could buy something like an Arduino Mega, with its extra sockets to fulfil your needs. But what would you do if you really needed more pins, say a thousand of them? Perhaps [Brian Lough] has the answer. OK, full disclosure: If you really need a thousand, the video isn’t exactly for you, as he shows you how to add up to 992 PWM outputs. The chip he uses works with any microcontroller (the video shows an ESP8266), and we suppose you could use two daisy chains of them and break the 1,000 barrier handily.

We like how short the video is (just two minutes; see below) as it gets right to the point. The PCA9685 chip gives you 16 12-bit PWM channels via an I2C interface. You can daisy chain up to 62 of the boards to get the 992 outputs promised.

[Brian] uses a cheap $2 breakout board that lets you set a 6-bit address, has a nice power connector and makes it easy to use the little surface mount device. Each of the 16 outputs on the board can have an independent duty cycle, but they do share a single output frequency. That means if you want to use some channels for low-frequency devices like motors and some for high-frequency devices like LEDs, you might have to spring $4 for two boards.

Over on Hackaday.io, we’ve seen these devices driving 128 vibration motors. The PCA9685 made us think of the time we rolled our own serial to PWM devices using an FPGA.

Hack a Day 12 Apr 00:00

Roll Your Own Arduino PWM

Most projects are built on abstractions. After all, few of us can create our own wire, our own transistors, or our own integrated circuits. A few months ago, [Julian Ilett] found a problem using the Arduino library for PWM. Recently, he revisited the issue and used his own PWM code to fix the problem. You can watch the video below.

Of course, neither the Arduino library nor [Julian’s] code is actually producing PWM. The Atmel CPU’s hardware is doing the work. The Arduino library gives you a wrapper called analogWrite — especially handy if you are not using an Atmel CPU where the same abstraction will do the same work. The issue arose when [Julian] broke the abstraction to invert the PWM output.

The video does a good job of framing the issue. Setting the PWM hardware to zero still causes a one tick output to occur. That is, the actual count is the count you supply plus one. That’s great on the high end where 255 is treated as 256 out of 256. But at the low end, a zero counterintuitively gives you 1/256. The Arduino library authors elected to detect that edge case and just force the output pin to go low in that case. When inverted, however, the pin still goes low when it ought to go high. You can see the source code responsible, below.

pinMode(pin, OUTPUT);
if (val == 0)
  {
  digitalWrite(pin, LOW);
  }
else if (val == 255)
  {
  digitalWrite(pin, HIGH);
  }
else
{ ...

Oddly, the 255 case appears to be superfluous in the normal case but is also backward if you invert the output. In all fairness, the Arduino library doesn’t provide you a way to invert the output, so you’ve already broken the abstraction and that’s why this isn’t technically a bug in the library.

[Julian’s] code is quite simple. There’s initial set up of the TCCR1A and TCCR1B registers along with ICR1. The DDRB register sets the pin as an output. After that, writing to OCR1A and OCR1B set the PWM value. The video explains it all in great detail.

We’ve looked at PWM on FPGAs at least once, and that post gives some background on PWM in any application. We also have our own video from way back in 2011 about PWM.


Filed under: Arduino Hacks
Hack a Day 12 Nov 12:00

Scrap Bin Mods Move Science Forward

A first-time visitor to any bio or chem lab will have many wonders to behold, but few as captivating as the magnetic stirrer. A motor turns a magnet which in turn spins a Teflon-coated stir bar inside the beaker that sits on top. It’s brilliantly simple and so incredibly useful that it leaves one wondering why they’re not included as standard equipment in every kitchen range.

But as ubiquitous as magnetic stirrers are in the lab, they generally come in largish packages. [BantamBasher135] needed a much smaller stir plate to fit inside a spectrophotometer. With zero budget, he retrofitted the instrument with an e-waste, Arduino-controlled magnetic stirrer.

The footprint available for the modification was exceedingly small — a 1 cm square cuvette with a flea-sized micro stir bar. His first stab at the micro-stirrer used a tiny 5-volt laptop fan with the blades cut off and a magnet glued to the hub, but that proved problematic. Later improvements included beefing up the voltage feeding the fan and coming up with a non-standard PWM scheme to turn the motor slow enough to prevent decoupling the stir bar from the magnets.

[BantamBasher135] admits that it’s an ugly solution, but one does what one can to get the science done. While this is a bit specialized, we’ve featured plenty of DIY lab instruments here before. You can make your own peristaltic pump or even a spectrophotometer — with or without the stirrer.

[via r/Arduino]


Filed under: chemistry hacks, tool hacks

Primer on Servos Hits All the Basics

Servos are pretty basic fare for the seasoned hacker. But everyone has to start somewhere, and there’s sure to be someone who’ll benefit from this primer on servo internals. Who knows – maybe even the old hands will pick up something from a fresh perspective.

[GreatScott!] has been building a comprehensive library of basic electronics videos over the last few years that covers everything from using a multimeter to programming an Arduino. The last two installments delve into the electromechanical realm with a treatment of stepper motors along with the servo video below. He covers the essentials of the modern RC-type servo in a clear and engaging style that makes it easy for the newbie to understand how a PWM signal can translate into positional changes over a 180° sweep. He shows how to control a servo directly with an Arduino, with bonus points for including a simple 555-based controller circuit too. A quick look at the mods needed to convert any servo to continuous rotation wraps up the video.

If [GreatScott!]’s video whets your appetite for more, be sure to check out [Richard Baguley]’s deeper dive into servos. And when you’re ready to put your new-found knowledge into practice, maybe a nice project would be to convert a hobby servo into a linear actuator.


Filed under: classic hacks, misc hacks

Smart street light using arduino

Introduction:

This project is about smart street light using arduino. This project consists of 3 analog IR (infrared) sensors. By default, the intensity of street light is set to 50 percent. We are using high intensity led as they have extra brightness. This project also features harnessing the solar and wind energy.
We are using a solar panel of  9 Volt, 2.5 watts and for wind mill, we are simply using a 12 volt dc motor.

Components required:
  1. Atmega 8a (based on arduino ng board)
  2. 8 high-intensity led
  3. Relay
  4. Perfboard
  5. 7805
  6. connecting wires
  7. solar panel (9 volt, 2.5 watt)
  8. Relay
  9. 12 volt DC motor.
How it works:

By default, the intensity of high intensity light (aka street light) is set to 50% pwm. We are using three channel of PWM. The first channel of pwm is controlling three leds, second channel is used for controlling two led's whereas the third channel is used for controlling three led at once. There are eight high intensity led. There are three, analog IR sensor, which can detect the vehicle. Upon detection of vehicle by the first sensor, it will increase the duty cycle of first three led's to 100% and by this the intensity of first three led will increase. Now, when vehicle reaches near second IR sensor first three led will again set to 50% duty cycle whereas the next two led will set to 100% duty cycle. 


IR sensor:

IR sensor is made up of simply IR led and photodiode. The connection is as follows:

DIY IR sensor

Check out the video:



Stay tuned for more updates !!






FunWithElectronics 14 Oct 05:08