Code Craft: When #define Is Considered Harmful

An icon of Computer Science, [Edsger Dijkstra], published a letter in the Communications of the Association of Computer Machinery (ACM) which the editor gave the title “Go To Statement Considered Harmful“. A rousing debate ensued. A similar criticism of macros, i.e. #define, in C/C++ may not rise to that level but they have their own problems.

Macros are part of the preprocessor for the C/C++ languages which manipulates the source code before the actual translation to machine code. But there are risks when macros generate source code. [Bjarne Stroustrup] in creating C++ worked to reduce the need and usage of the preprocessor, especially the use of macros. In his book, The C++ Programming Language he writes,

Don’t use them if you don’t have to. Almost every macro demonstrates a flaw in the programming language, in the program, or in the programmer.

As C retrofitted capabilities of C++, it also reduced the need for macros, thus improving that language.

With the Arduino using the GNU GCC compilers for C and C++ I want to show new coders a couple of places where the preprocessor can cause trouble for the unwary. I’ll demonstrate how to use language features to achieve the same results more cleanly and safely. Of course, all of this applies equally when you use any of these languages on other systems.

We’re only going to be looking at macros in this article but if you want to read more the details about them or the preprocessor see the GNU GCC Manual section on the preprocessor.

Continue reading “Code Craft: When #define Is Considered Harmful”

Hacklet 80 – Gigahertz Projects

Somewhere between the HF projects many of us have worked on, and the visible light spectrum lies the UHF, EHF, SHF, and THF. That’s Ultra, Extremely, Super, and Tremendously High Frequency for those who aren’t in the know. All of them involve frequencies in the gigahertz and terahertz range. While modern computers have made gigahertz a household term, actually working with signals in the gigahertz frequency range is still a daunting prospect. There have always been an elite group of hackers, makers, and engineers who tinker with projects using GHz frequencies. This week’s Hacklet is about some of the best GHz projects on Hackaday.io!

radar1We start with [Luke Weston] and Simple, low-cost FMCW radar. For years people like Hackaday’s own [Gregory L. Charvat] have been building simplified radar systems and documenting them for the rest of us. [Luke’s] goal is to make radar systems like this even more accessible for the average hacker. He’s put all the specialized parts on one board. Rather than large Mini Circuits modules, [Luke] went with Hittite microwave parts in chip scale packages. Modulation comes from a Microchip MCP4921 mixed signal DAC. The system works, and has demonstrated transmission and reception 5 GHz to 6 GHz bands. [Luke] has even demonstrated detection of objects at close range using a scope.

Continue reading “Hacklet 80 – Gigahertz Projects”

Looking Inside The Arksen Dual Power Supply

I recently picked up an Arksen dual power supply. You’ve seen these before, I’m sure, under a variety of names in places ranging from electronics stores to eBay. They look amazing for the price, and while I didn’t expect it to measure up to some of the pro supplies I have, I just wanted something to stick under my desk instead of having to move things to the bench or–worse–drag a heavy power supply over to my desk.

When I was putting together the sonic motion sensor, I found that the HC-SR04 module needed more current than I could draw out of an Arduino Leonardo. I figured this would be a good chance to use the new supply in anger. It seemed to work without too many problems. But there were a few things you might want to know if you have a similar supply or are thinking about getting a similar one.

Continue reading “Looking Inside The Arksen Dual Power Supply”

Hackaday Dictionary: Near Field Communications (NFC)

You are at the corner store, buying gum. The cashier rings up the purchase, showing you the amount. You casually pull out your cell phone and wave it near the credit card machine, which beeps appreciatively. The cashier nods, and you walk out, stuffing gum into your face. What just happened? You used Near Field Communications (NFC) to send data between your phone and the credit card terminal.

NFC is a standard that allows two devices to exchange information over a short distance without being in physical contact. The two devices communicate using a weak magnetic field that, in theory, only has a range of a few centimeters, so both devices have to be physically close, and someone standing nearby can’t intercept or alter the signal.

Continue reading “Hackaday Dictionary: Near Field Communications (NFC)”

ASCII Games, Chiptunes, Hacker Celebrities At Hackaday Prize Worldwide Berlin

Hackaday teamed up with the Vintage Computer Festival to have a Meetup last week. It was quite a party, with Berlin based chiptunes band Thunder.Bird and TheRyk using Commodore 64s and SID sound chip. The age of this equipment and relatively small volume original production runs makes it hard to find these days, but there is an underground group making music with these who trade among themselves. TheRyk created PlayEm64 (pictured above) to organize and play the music using the SID hardware and says that an advantage of this software is that it includes the play time (not in the fileheader), which is really useful for party entertainment! These chips sounded fantastic and added to the energy of the packed house.

zoovideoA Hackaday party means that people bring their projects to show off and entertain the crowd with. [Nils Dagsson Moskopp] brought a game called Zoo Tycoon Roguelike that he built for a 7 day long competition. This is a text based roguelike game based on the 2011 Microsoft game Zoo Tycoon. As with the original game, Nils’ game aimed to keep animals happy within a thriving zoo. What’s neat about Nils’ version is that all the actions are displayed in words on the right side of the screen and he custom developed the characters in bitmap form.

SONY DSC
[Sisam] brought Cube Tetris, a social gaming device with 4 sides, each individually controlled so that players must collaborate with each other to win. The new take on the already addictive game kept a crowd around this table the entire night.

[Dave Darko] and [Alex] brought a collaborative project that they’ve been developing on Hackaday.io together. The first, third and 4th board shown below are [Alex’s] boards, and the second one with the acrylic case is [Dave Darko’s]. They both started with 5x5cm breakout boards for the ESP8266 but they’ve been adding features off of each other’s boards like support for the ESP-07 / ESP-12 and an additional ESP-01 footprint. Someone wished for a USB micro port, and that is now on both of their boards. The next stage for [Alex] is adding 2 pin rows for GVS (ground-voltage-signal) to his boards, a feature which [Dave Darko] has already put in place on his offerings.

We also saw an appearance by Captain Crunch (John Draper) – he’s pictured here with some friends from Lithuania. Our next event is in San Francisco in November, and we hope to see you at some point somewhere in the world.

The 2015 Hackaday Prize is sponsored by:

Hacking When It Counts: Much Space Station Hacking Saved Skylab

Thanks to the seminal work of Howard and Hanks et al, the world is intimately familiar with the story behind perhaps the most epic hack of all time, the saving of the crippled Apollo 13 mission. But Apollo 13 is far from the only story of heroic space hacks. From the repairs to fix the blinded Hubble Space Telescope to the dodgy cooling system and other fixes on the International Space Station, both manned and unmanned spaceflight can be looked at as a series of hacks and repairs.

Long before the ISS, though, America’s first manned space station, Skylab, very nearly never came to fruition. Damaged during launch and crippled both electrically and thermally, the entire program was almost scrapped before the first crew ever arrived. This is the story of how Skylab came to be, how a team came together to fix a series of problems, and how Skylab went on to success despite having the deck stacked against her from the start.

Continue reading “Hacking When It Counts: Much Space Station Hacking Saved Skylab”

Skarp Laser Razor Kickstarter Suspended, Jumps To Indiegogo

An irritation-free razor that gives a close shave has been a dream for thousands of years. [Gillette] came close, and with multiple blades came even closer, but all razors today are still just sharpened steel dragged across the skin. This is the 21st century, and of course there’s a concept for a laser razor pandering for your moola. We recently covered the Skarp laser razor and its Kickstarter campaign, and today the campaign has been shut down.

The email sent out to all contributors to the Skarp campaign follows:

Hello,

This is a message from Kickstarter’s Integrity team. We’re writing to notify you that the Skarp Laser Razor project has been suspended, and your pledge has been canceled.

After requesting and reviewing additional material from the creator of the project, we’ve concluded that it is in violation of our rule requiring working prototypes of physical products that are offered as rewards. Accordingly, all funding has been stopped and backers will not be charged for their pledges. No further action is required on your part. Suspensions cannot be undone.

We take the integrity of the Kickstarter system very seriously. We only suspend projects when we find evidence that our rules are being violated.

Regards, Kickstarter Integrity Team

It only took eight hours for the Skarp team to relaunch their crowdfunding campaign on Indiegogo. As of this writing, over 900 people (ostensibly from the 20,000 backers of the original Kickstarter campaign) have pledged to the new campaign.

Although we will never know exactly why Kickstarter suspended the original Skarp campaign, the reason given by the Kickstarter Integrity Team points to the lack of a working prototype, one of the requirements for technology campaigns on Kickstarter. Interestingly, Skarp did post a few videos of their razor working. These videos were white balanced poorly enough to look like they were filmed through green cellophane, a technique some have claimed was used to hide the actual mechanism behind the prototype’s method of cutting hair. A few commenters on the Skarp Kickstarter campaign – and here on Hackaday – have guessed the Skarp prototype does not use lasers, but instead a heated length of nichrome wire. While this would burn hair off, the color of the wire would be a dull red when filmed in any normal lighting conditions. It is assumed the poor quality of the Skarp prototype videos is an attempt to hide the fact they do not have a working prototype.

The Skarp laser razor. Source
The Skarp laser razor. Source

Skarp’s move to Indiegogo has been lauded by some – mostly in the comments section of the Indiegogo campaign – and has been derided on every other forum on the Internet. Indiegogo is commonly seen as the last refuge of crowdfunding scam artist, but there are a few legitimate reasons why a campaign would choose to go to Indiegogo. Kickstarter is not available for campaign founders in all countries, and for some, debiting a card immediately, instead of after the campaign end like Kickstarter does, is a legitimate crowdfunding strategy.

But for a crowdfunding campaign to be suspended on Kickstarter and immediately move to Indiegogo? This almost never ends well. One of the most famous examples, the Anonabox, had its Kickstarter campaign suspended after it was found the creator was simply rebadging an off-the-shelf router. The Anonabox then moved over to Indiegogo where it raised over $80,000. Already the campaign for the Skarp Laser Razor has raised $135,000 USD from Indiegogo, after having its Kickstarter campaign raised over $4 Million. No, Skarp won’t be one of the most successful technology Kickstarter campaigns of all time. We can only hope it won’t be one of Indiegogo’s most successful campaigns.