Monthly Archives: September 2014

Remaking MSR206 RS232 magnetic card reader to USB

As you might have noticed, sometimes I work as freelancer in electronics =) It applies not only to fixing PC electronics and mobile phones, but also to repairing, modifying and designing my own solutions in consumer electronics. One of the projects I worked on yesterday is modifying MSR-206 magnetic card reader to replace RS232 port with USB. Let me tell you about that…

IMG_0830

This was of high urgency, so I’ve had to suspend my usual work activities and concentrate on this project yesterday. MSR-206 is a pretty impressive piece of technology, incomparable to those cheap eBay magnetic card readers. It even includes 24V 2.2A DC power supply, which is quite heavy and makes you question those cheap USB 2.5W card readers – like, are they really OK for most applications when somebody released such a powerful thing just to accomplish the same task? It’s also kind of state-of-art inside… Well, maybe it’s just me being used to see a lot of disassembled Chinese stuff =)
Unfortunately, it also is quite old – it has only RS232 port in 8P8C (Ethernet cable) form-factor, not to mention non-standard wiring. My acquaintance working as the IT guy in one hotel had to replace the receptionist PC with a newer one. He didn’t think of need of having a COM port, though. Also, the original COM-8P8C cable was lost, and, of course, cheap COM-8P8C cable for connecting to network equipment didn’t work. So – there’s a hotel that needs their equipment to be in working state ASAP…Which meant replacing RS232 with USB. RS232… I instantly sensed MAX232 chip inside.

So – I disassembled this card reader. Looks great, doesn’t it?

IMG_0831

OK, the top part doesn’t mean much to us. Let’s pull out the PCB:

IMG_0833

On the left side, you can see something related to a power supply. Logic runs on 5V anyway – so I’m not supposed to look closer and examine =)

IMG_0836

L293D? OK, maybe there is a motor or some kind of motor-like thing inside =) Wasn’t exactly my job to figure it out.. 3 of them is something, though. I also didn’t want to see what’s the chip with a sticker on top – must be a MCU, and I knew it didn’t matter to me because I wouldn’t understand it anyway =) Those old MCUs are a PITA when you have to somehow change contents of the ROM or something like that.

IMG_0837

Some kind of logic elements… OK, that’s not what I’m searching for. Let’s see the bottom side of PCB.

IMG_0838

A lone transistor/regulator… Doesn’t matter much.

IMG_0840

Some more logic elements, I guess I’ll have to examine them in case somebody got high and implemented UART-RS232 using buffered logic gates.

IMG_0841

Woohoo! The object of my search. As you know, MAX232 has 2 RS232->TTL (R-T) elements and 2 TTL->RS232 (T-R) elements inside. One pair of R-T&T-R is RX and TX. Other pair is usually unused… Usually. Let’s desolder the chip to see what’s actually used…
IMG_0843
Sorry, sticker, you just were at the wrong place at the wrong time.
IMG_0844
Oh. All 4 elements are used. That’d mean trial and error =( That’s the moment when I realised that I should give Google a try. What I’ve got? A programmer’s manual! Pinouts, commands and so on! Excellent!

First of all, manual doesn’t mention 2 of 4 lines coming from MAX232 to the 8P8C connector. I guess they aren’t that significant then. Other two lines are TX and RX and wiring for MAX232 is exactly the same as on this circuit diagram:

So I soldered 3 wires to GND, TTL RX and TTL TX. What you’d need a chip for then you can interface USB to TTL directly? That’s when a USB-UART converter appears on the stage.
IMG_0850
It’s based on ARK3116 chip, which works on Linux and Windows. I guess now it’s time to say – what a shame that Windows drivers aren’t open-source! This chip works with both x32 and x64 Linux versions, but doesn’t work with Windows x64 – exactly the OS that hotel uses. They’ve installed x32 OS on reception, though – PC wasn’t configured yet and it wasn’t that hard. This board is so small because it was inside of a mobile phone interfacing cable.

So – I soldered headers to the cable that carried TTL signals (the one I soldered instead of MA232). First, I’ve tested them using a FTDI breakout board – it was guaranteed to work good. You know, I’vehad some problems with USB-UART converters in the past =) I issued a command that turns all 3 indicator LEDs on the board… It didn’t work. I swapped TX and RX and – voila!

IMG_0848
Photo (sorry, not screenshot) of my monitor – programmer’s manual on the left side, cutecom terminal on another:
IMG_0849
BTW, Cutecom is a great serial terminal with a GUI =)
Now it’s time for ARK3116 with a USB-B socket soldered to it. That’s when things went wrong – I had wiring problems, soldering problems, adapter problems, software problems and so on. After an hour or so, it finally was OK:
IMG_0851IMG_0852


“[ 587.976696] usb 6-2: ark3116: don’t know how to do software flow control

Sorry, converter, neither do I.

It worked… The only problem was that case wouldn’t close. Turned out that I needed to reposition the converter somewhere else. Like this:
IMG_0853
Cover with a bit of masking tape:
IMG_0854IMG_0857
*puts sunglasses on* Case closed. Now testing with original Windows-only card reading/writing software:
IMG_0858
Woohoo! Ready to be given back to the hotel.

IMG_0855

One more thing for my portfolio in freelance electronics 😉 That sure was fun to make and I hope that’ll inspire somebody. Now – back to writing software for my Arduino payphone project.
BTW, my part-time job now is software testing. It seems that the job changes me already – I’ve found a bug in Tetris:

IMG_0859

tetris-bsd from bsdgames package

Advertisements

Payphone project – screen problem solved & parts arriving

I’ve got some updates for the payphone project. First of all, a photo of the actual payphone I’m modifying. It’s a GPT Sapphire payphone, and there were a lot of payphones like this in Latvia just some years before. Now there are no payphones like this on the streets =(

Now, something about the HD44780 screen. First, this screen compared with the cheapest chinese HD44780-compatible screen:
IMG_0817

As you can see, they differ not only in sizes, but also that the header is not at the right place. What a shame =(

As I’ve told you, I’ve ordered replacement comtroller ICs for the display. They’ve arrived:
IMG_0746
A closeup shot:
IMG_0757
So – I’ve desoldered original ICs and soldered the new ones on the board.

IMG_0750IMG_0751IMG_0755IMG_0753IMG_0754IMG_0762

Still didn’t work! Why? Amused, I connected the display to the payphone… Only to see it working.

IMG_0792

What was it? I’ve had a guess, and I guessed it right.

IMG_0793

Seems that my HD44780 screen needs negative contrast voltage in order to display something. Couldn’t have known that earlier – there isn’t much information on this on the Web, and I can see why – it’s an extended temperature range screen, they aren’t that popular. I’ll need to make a negative charge pump in order to power it… BTW, would be a nice idea to see just how much current it needs on the contrast line – to understand which charge pump is needed. If it’s under 0,5 A, I can use a well-known 7660 IC. If not, well, that’s sad – that’d mean I’d need somebody to help.

Some info about this phenomena:
First clue I’ve found that helped me understand;
Actual screen modification that provides some info on how and why;
Just a bunch of photos of different displays =)

Also, I’ve received DTMF generators (datasheet) and decoders (datasheet)… But I haven’t got the crystals for them yet – they’re to arrive soon =( I’ve made breakout boards for both, but, as you can see, they lack some passive components and crystals.
IMG_0818IMG_0818

(Left – a ready board, center – DTMF decoder board w/o crystal and passive elements, right – DTMF generator board w/o crystal)
In order to understand my breakout circuit, just look at the datasheets, there’s a section with a sample usage. The breakout board with a crystal and IC is MT8870 DTMF decoder board – it’s basically the same IC, just older and from another manufacturer, but pinout and circuit are the same. I’ve made this board around 3-4 years before =) That might be one of the reasons it doesn’t work so well – my soldering wasn’t so good back then.
I also plan on making breakouts in Eagle CAD, just after I test these hand-made boards. I’ll share them here – along with some more useful breakouts I hope I’ll finally get an opportunity to test.

I’ve received a I2C-to-HD44780 interface converter, or, as they’re called, I2C LCD backpack.

IMG_0816

It’s also a Chinese version – so it’s not amusing it doesn’t work with the popular I2C LCD backpack Arduino libraries. Why? Seems that pin mapping between I2C-GPIO IC that’s on the backpack board and LCD header on the same board just isn’t the same as in popular versions of this kind of backpack. We’re left to guess just why they’d manufacture a backpack like that, yet it isn’t the prettiest thing to do. At least they’ve supplied Arduino libraries and example code… Which doesn’t compile in my Arduino IDE, and I don’t even want to know why ’cause I sure don’t want to translate code comments from Chinese. I suppose modifying some library that is already working just to have the bits of data sent in different order won’t be any hard. Also, it has a backlight control pin connected to the I2C-GPIO chip, so that’s a bonus =)

I plan on doing the next update when I’ll receive crystals and complete my breakout boards. I’ll probably have Eagle-made breakout boards and libraries for DTMF chips to share by then, too =) Not to forget Arduino libraries.

Debian Jessie, VirtualBox – driver compilation failing because kernel sources cannot be found

I installed the Debian Jessie (testing) system from an around 3-month-old CD. Then I installed virtualbox and while installing it has complained that kernel sources are not found. I’ve installed linux-headers package and all the linux-headers packages that I could have found, but still no luck. I kept getting the following message:


The VirtualBox Linux kernel driver (vboxdrv) is either not loaded or there is a permission problem with /dev/vboxdrv. Please reinstall the kernel module by executing

‘/etc/init.d/vboxdrv setup’

as root. If it is available in your distribution, you should install the DKMS package first. This package keeps track of Linux kernel changes and recompiles the vboxdrv kernel module if necessary.


/etc/init.d/vboxdrv didn’t even exist! As I knew VirtualBox used DKMS, I did aptitude reinstall virtualbox-dkms, and it still outputted “Module build for the currently running kernel was skipped since the kernel source for this kernel does not seem to be installed.” I even installed linux-source – it didn’t help. So what was it?

My distribution had an older kernel, as it was on the CD I installed everything from. Since then, things changed – 3.13 was replaced by 3.14. The repository only had linux headers for 3.14 – and when I installed linux-headers metapackage, I installed headers for 3.14, even though system used the 3.13 kernel. So – when a vboxdrv can’t be build, check if you really have headers for the kernel version you are using =)

Now I just need to learn how to read properly. And to reboot my PC =)

Minimizing Eagle-made boards

Disclaimer: I haven’t yet tested any of these projects as currently I haven’t got a possibility to print PCBs even using the toner transfer method. So use them at your own risk – as you should do with any other project on the Internet =)

From time to time I find cool PCB projects on the Web that are just too big for my use or otherwise unsuitable. Sometimes, those are proprietary and you cannot do anything about it. Other times, source files are available and I use my Eagle CAD knowledge and just minimize the PCB dimensions, replacing components and throwing out useless parts =) The power of open-source hardware, hell yeah. Anyway, here are three Eagle CAD projects that I’ve minimized and would like to share.

1) Tiny USB LIRC-compatible receiver

I was searching for a really tiny USB IR receiver for my laptop. I’ve been searching for a long time but it seemed that every solution wasn’t fitting and had one of three problems: 1) not tiny,2) not USB, 3) not for laptops. Finally, I’ve found a solution on this page that is also full of research on the topic… Still not small enough, but the page includes Eagle CAD files! So I’ve got them and opened them, and noticed that connectors could be replaced in favor of smaller ones. (USB-B for MiniUSB) I did that, rearranged the components on the board and it looked nice. That was the first version – the second has 4 holes for wire instead of connector, which makes it even smaller and embeddable – I plan to embed one in my laptop, one in my Raspberry Pi project and keep some assembled receivers in the drawer just for other projects =)

  • First version – photo (some traces are interrupted but it’s OK – you have to use “Ratsnest” tool, so you get a nice ground fill polygon):
  • Initial version – Eagle files are on the same page where I’ve found the circuit
  • Second version – photo (you can compare boards by looking at the FTDI IC):
  • IR receiver
  • Second version – Eagle files

2) FTDI SIM card reader

This is a quite nice thing that Adafruit used to sell as kits for assembly. It included FTDI and RS232 interfacing circuit – I’d call the second part useless in our days, since nobody’d use COM port when there’s FTDI header available. I took the schematics, threw out everything that was related to RS232 and made the board as little as possible. Almost all the remaining components were replaced with their SMD variants, so this board now is as wide as SIM socket and just a little bit longer =) I guess I’ll order 5 PCBs of this after a while – just after I figure out why the heck I’d need them 😉 I’ll definitely have to extend the capabilities of the SIM card reading software that Adafruit provides (I guess it’s not actually made by them, but I’ll find the owner and fork his repository 😉 ).Also, I’ve made an eBay collection with needed parts in bulk, so that when time comes I can easily order everything – and so can everyone.

By the way, before making this board, I’ve assembled a deadbug-style prototype that actually is even smaller and works with USB-FTDI converter without any problems. Here’s a photo for you:

3) 12V-220V power inverter

This Arduino project  by techmind.dk was featured at Hackaday some time ago and I got interested in it, having searched for something like that for a long time. It’s an inverter that takes 12VDC (or whatever here is) and converts it to the 220VAC. It’s controlled by AtMega 168P in DIP package, and there were no SMD components in the original circuit at all. I decided to fix that and asked the author about original .sch and .brd files – fortunately, he shared them. You know, many people just do not share their original files – and I guess that’s one of the biggest mistakes a person can make when designing something that wouldn’t be much of a problem to open-source. See, when all that’s
between a slightly useful project and quite useful project is uploading some files to a hosting, I prefer the latter.
Anyway, I opened those files, replaced through-hole components with SMD and rearranged the elements… I also needed to retrace the whole board, I’d say it was quite challenging =) I don’t know if it works as good as the previous version, though – haven’t tested yet, but you’d definitely need to change some pin assignments in firmware – I mean, LEDs and maybe something else I’ve forgot about, just compare the schematics and you’ll see – I’ll probably do this make a follow-up as soon as I’ll make this board myself. I think I’ll replace temperature sensor with DS18B20, but that’s just an idea.

I’ve already got more minimized projects that I’d like to tell you about, but I guess it will be later – after I check if they’re, in fact, working =)

The software awards scam

Well, that’s another example of how it goes.

Successful Software

software awardI put out a new product a couple of weeks ago. This new product has so far won 16 different awards and recommendations from software download sites. Some of them even emailed me messages of encouragement such as “Great job, we’re really impressed!”. I should be delighted at this recognition of the quality of my software, except that the ‘software’ doesn’t even run. This is hardly surprising when you consider that it is just a text file with the words “this program does nothing at all” repeated a few times and then renamed as an .exe. The PAD file that described the software contains the description “This program does nothing at all”. The screenshot I submitted (below) was similarly blunt and to the point:

awardmestars_screenshot.gif

Even the name of the software, “awardmestars”, was a bit of a giveaway. And yet it still won 16 ‘awards’. Here they are:

all_awards2.gif

Some of them…

View original post 1,089 more words

Project: Payphone remake

One of my current projects in R&D stage is converting a GPT payphone to Arduino platform while preserving all the abilities and keeping its outside as-is. This is a project I’ve started to plan when I was asked to unlock this payphone. See, they have smart card system inside which somehow is responsible for security of the payphone and all that stuff… And the payphone effectively fails to work both with or without a small internal SIM-like smartcard, it’s locked with it and not working without it.
So what? We have a payphone that is useless, even though it’s a masterpiece inside – i’ll show you why.
Without any clue about how to unlock anything on existing hardware, I’ve got an idea… What if I could replace everything that relies on smartcard system (that, unfortunately, means about 75-85% of all electronics in the payphone) with self-developed solution that’d even be upgradeable in terms of its capabilities? That is, we take a MCU, we take all the other parts that we’d need to make a landline-connected phone, put them all together and write the firmware so that they all work together. Great, isn’t it?

When I had to choose a base, I chose Arduino. Why? Development will be easy for me because of great choice of libraries, my knowledge of Processing used in Arduino and huge count of people that are ready to help. Also, there surely are people who might repeat my project, and Arduino would be great for beginners. But… How the hell do you connect Arduino to a landline, let alone make it work as a payphone?

Turns out this isn’t easy, yes. AFAIK, Arduino cannot work with voice, so I’m kind of limited in what capabilities the payphone can have. However, we can leave alone voice synthesis and concentrate on how the heck do those two thin wires that come to our phone make sound…
It’s called DAA interfacing, and I’ve found around 10 articles or posts from people who had it implemented on different platforms. Turns out that you’d have legal problems connecting things to your landline… So – there’s a solution, called DAA interface module, it’s a bit like IC because it has all the needed components in one package, furthermore, it’s FCC approved. It takes those two wires and has contacts to connect the microphone, speaker and some more helpful contacts, such as signalling when there’s an incoming call and when the handset is lifted. Some even have Caller ID contact, although it’s not my case as currently I cannot find any DAA interface which has it and is in stock. Problem is – they’re old and they’re not manufactured anymore. Therefore, stock is not so great as I’d wish it was.
I’ll be ordering two different DAA module ICs:
1) CH1817 – datasheet is here, I’m getting them from here
2) CH1812 – datasheet is here, I’m getting them from here (same seller)

I’ll need to hook up a DTMF decoder to the module’s audio output and a DTMF generator to the module’s input. I’ll also need to mute microphone pre-amp for the time that DTMF generator will make sound. I’ll need something to control keypresses. There are keys on the payphone – and I need to preserve both them and PCB that has all the contacts for keys on it. I plan on cutting traces that lead to keys, disabling them from the rest of the PCB and wiring some kind of keypad controller IC to them. Maxim has one, it has I2C interface and does everything that’s needed – but it’s only QFN, no SOIC package available… There’s a need for a breakout, for sure =)

What about DTMF? Those old codes that phones and, recently, some robots and DIY smart house systems, are using to reliably encode and decode numbers over unreliable and limited phone lines? Well, Holtek seems to be partly targeted at that. They have both DTMF encoder and decoder ICs available, which are easy to control and cheap on eBay. Holtek even has a caller ID decoder IC available, even though I don’t yet know whether I’ll be able to implement that – it has some limitations =( All those ICs are easy to hook up to Arduino, there isn’t much code to be written and they’ll provide all the necessary functions.
By the way, the payphone has a nice HD44780 controlled screen. This screen has a connection header that is fully compatible with all those cheap 16×2 HD44780 screens, all the pins are of this header connected to right pins on HD44780 (I checked with an ohmmeter). In short, differences between this screen and any cheap 2-dollar HD44780 display on eBay are following:
1) Non-standard dimensions – this screen is 1,5 times bigger than all the screens available. Finding another one with the same dmensions would be quite a pain in the ass.
2) It doesn’t freaking work for me yet =(
I’ve ordered replacement controller ICs – there are two of them on a display board. BTW, those are quite hard to find – thank god I’ve found some offers on Alibaba. Well, they were expensive =(
I’ve added a diagram I made in Dia, it explains what’s connected to what =)

diagram

What I’ve ordered?

  • DTMF generator – HT9200
  • DTMF decoder – HT9170
  • Two solderless breadboards – for prototyping (already arrived)
  • Replacement controller ICs for the display – HD44780 and HD44100
  • Arduino Pro Mini MCU
  • DAA modules – I’ll be using only one but you can never be sure, things happen to break at the wrong time =)
  • RTC module – using DS1307 chip and the breakout I’ve developed by myself.

I haven’t yet ordered the keypad controller IC, unfortunately. If I won’t have it in time, I’ll make a keypad controller using a spare Arduino Pro Mini =) Here’s my eBay collection for this project – includes almost all the parts I’ve bought.

Some links, projects and articles about DAA interfacing:

  • This is probably the best article. It’s very close to my project and I guess I learned a lot from it. For everybody that will follow the same path as I did, this has to be read through.
  • This article provides a lot of nicely explained theorethical information about designing your own DAA interfaces. I won’t be following this path because DAA module is claimed to be safer, but it was nice to know more about what am I actually doing 😉
  • This is a price list from Cermetek, company that used to produce those DAA modules. Has nice datasheets of ICs that currently can’t be found anywhere 😉
  • This site sells spare parts for GTP Sapphire payphones. Just so you know =)
  • This is a project with handmade DAA interface – a landline-controlled alarm. If you can’t get a DAA module, take a look here – and don’t forget that theorethical article above so that your interface works instead of catching fire!
  • One more dial alarm with DIY DAA interface. This is described much better than the previous one =)
  • Sample project with DTMF generator hooked up to the phone line. Has some info about transformers and stuff.

More photos of this payphone:

IMG_0567

That’s how it looks inside. Right part is security+DAA+MCU module, box on the left is a coin counting box, which hides a card reader/keypad/accu charger/display modules.

IMG_0564

This module seems to be some kind of safety/power module, unfortunately, when I was doing research on it, I couldn’t connect it to the landline to check. When I’ll be assembling everything, I’ll retrace the schematics and fully understand what it does.

IMG_0565

Card reader module. Probably even has some actuators to push the card out – I didn’t look, I just guess.

IMG_0568IMG_0569IMG_0570IMG_0571IMG_0572

Some photos of main board (right side). Contains DAA and many, many general-purpose 15-year-old datasheetless MCUs that would be impossible to reverse-engineer. Also contains a DB9 port, must be COM – will see when I’ll work on it.

IMG_0573

Security module. So much of a mess because of this PCB and some code in those MCUs that, apparently, says “Nothing will work without a proper authentication on my watch!”

IMG_0632IMG_0633

 

Display, keyboard controller, accumulator controller and all that stuff. 

IMG_0637IMG_0639

IMG_0640IMG_0641

More about keypad

IMG_0634IMG_0636IMG_0635

 

The display. Why doesn’t authentic HD44780 IC work using the same protocol as all the other displays on this IC use?

IMG_0574IMG_0575IMG_0576IMG_0577IMG_0578

Some stickers from inside of the payphone. Google search for “Multipaymond” gives 0 results… Now there will be one =)

Wait for updates – there sure will be some when I’ll get all the parts!