Do touch my packs, if you please, Mr. Customs man!

Must be some kind of planet
For all the people who can manage.
All of us who can handle it,
With all of this damage.

The Dandy Warhols, “Plan A”

It feels strange to type into WordPress after two years of complete abstinence and four years since any actual work on this project. It’s already year 2015, and last time I had something to say it was back in 2011! For sure, there is good reason for me writing a new post now. But let me not run too fast, or else I will spoil all the joy from readers. Instead of telling right away my reason for posting, I will start telling a story of how the things came, or what the goddess lady Fortuna (who may be the same person as the ancient Greek goddess Tyche) brought about.

Two and a half months ago, an email came in from a gentleman under the name of Victor, who lives in Canada. Victor stated he was interested in both my Open USB FXS and Open USB FXO projects. I patiently explained to him that Open USB FXO is very much in a complete failure state, and he should not expect anything working out of it. In vain. Victor insisted that he was sincerly and truly interested in the project whatever its status was, and he asked that I sent him any materials I had in order for him to build an Open USB FXO board.

Which I did: I unburied my forgotten carton box with the ingredients of Open USB FXO project out of inexistence, dag carefully into it and fished out what I had to in order to compile a kit. As a side note, never before had I compiled an Open USB FXO kit, because I would never pass to anyone something that doesn’t work. Compiling such a kit felt anyway strange…

Then, the package I sent to Victor probably was of great interest to the Canadian Customs Office, who withheld it for five (!) weeks of processing. I guess that, during this time, the Customs authorities had ample time to fully analyze the contents of the kit, make sure it did not contain any harmful substances, and even verify the correctness of the resistance values typed with miniscule letters on the tiny 603 resistors! They must have also had enough time to reverse-engineer the code flashed into the PIC 18LF2550 that was included with the kit into high-level C code, and I am pretty much sure that they checked on the BOM, too, and verified that the kit was complete. Anyways, it is good to know that there are interested hobbyists everywhere out there.

Against all odds, the fact that the Customs guys took their time to process my package was a lucky coincidence.

Why, might you ask. The answer is that, because in the meantime, Victor and I had the time to discuss a bit about the status of the project. And Victor, who proved a very methodical guy, not having in his hands an actual kit to play with, found it useful to devour (information-wise, that is…) the whole PIC18(L)F2x550 manual. And, when he came down to page numbered 362, he noticed that nice graph on Figure 28-2. What this graph says is that the maximum frequency of the PIC18LF2x550 is dependent on the supply voltage. Put in other words, the graph clearly said that this otherwise fine device will not run in 48MHz unless powered with 4.2V or more! No wonder my FXO board did not even start on USB power.

Victor just had found the (first, and doubtedly the only) flaw in my design. Open USB FXO, as currently designed, will never work. While at first it would seem that using a lower frequency is a workaround, actually it is not: the TMR1 interrupt service function that implements the PCM bus (you will have to consult my Open USB FXS blog for more information on what this function is and how it works) will not tick correctly unless the processor core is clocked at 48MHz.

So, what is next? How could we fix that? Well, there are two paths. Let me go back to the reasons for selecting a PIC 18LF2550 for this design: it all has to do with interfacing with the (3.3V) chip Si3050. Hence the trick with the BAV99 double diode, to drop the USB-supplied voltage to approx 3.3V. But then, this PIC will not work at 3.3V/48MHz. It must be powered at 5V. So, what could be done?

Solution #1 (and the one adopted by Victor) would be to stick to PIC18F2550@5V and use a 5V/3.3.V lever converter chip between the PIC and the Si3050. This would have to interface all the SPI and the PCM bus signals, namely SCLK, SDI, SDO, CE for SPI and FSYNC, PCLK, DRX and DTX for PCM. Plus the INT and RESET signals, this totals to 10 signals. Wow, that’s a lot!

Soluion #2 may be a bit more dangerous, and it’s the poor man’s equivalent. It consists in using the 18LF2550, still at 5V, and use resistor-based level reduction for the signals from the PIC to the Si3050 (SCLK, SDO, CE, FSYNC, PCLK, DTX). How about the other four? Well one could gamble on these, and attempt to interface them directly to the PIC18LF2550’s inputs. According to the manual, when powered at 5V, any input with a level of 2V or more is interpreted as a logical one. Logical one outputs from the Si3050 would be close to 3V, so that path looks safe enough (and cheaper than a level converter chip).

Again, I think that we owe much of this to the Canadian Customs authorities who have delayed the package. That’s why I used this, slightly rephrased lyrics from Arlo Guthry’s song “Coming into Los Angeles”. I guess Arlo was afraid of what the officers would find in his bags. While we were lucky they did check my package. I don’t know what they found. I know that all of us did: Victor found a solution, and the Open USB FXO project found a new father. It also found new hope of becoming a reality. A great thanks to Victor, goddess Tyche and the Customs! All of those who did handle it with all of this damage!


5 Responses to “Do touch my packs, if you please, Mr. Customs man!”

  1. rc Says:

    Any progress on this guys ? If you need help with hardware or firmware, I am more than happy to contribute. Right now I am trying to figure out how to write a device driver for linux and for asterisk once a USB based FXO device is available? Would you use Zaptel ? or create a custom channel driver ?

    • Angelos Varvitsiotis Says:

      Hi Rajar,

      Thanks very much for your interest. The truth is I do not know how fast Victor will progress with what is now mostly his own project. If you do not mind, I can pass him your e-mail address and perhaps you two would work faster on that if you join forces.

      As for the device driver, you should really consult the Open USB FXS Dahdi (ex-Zaptel, that is) driver, called oufxs, to be found here: (for a short time, until I migrate my code to github). An Open USB FXO driver would be quite similar to that. As a matter of fact, one could use the same driver for both FXS and FXO.

      I hope this helps and I apologize for taking that long to reply. Please let me if you want me to share your email with Victor. You can reach me at openusbfxs -at- gmail dot com for a faster response.



      • Rajjar Code Says:

        Dear Angelos,

        Thanks a lot for your reply. Please forward my details to Victor. Hopefully we can get this going.

        Just last week I ordered the development kit for the Si3050. It’s on it’s way and once I have it, I can start getting my hands dirty.

        I am really struggling to make sense of the USB driver and how to make it work. Is there any design document or API for the FXS driver you modified ?

        Cheers, Raj


      • Angelos Varvitsiotis Says:

        Hi Rajar,

        Linux device drivers are not exactly the easiest type of software on earth. The Linux kernel developers supply a “skeleton” USB driver along with the kernel source. An idea would be to check that before you try to understand oufxs.c. The isochronous part is another difficult thing, because everything there is provrammed with an interrupt logic. If I can do anything more to give you more specific help, like answer questions of the sort “what does the code at line XYZ do?”, please do not hesitate to ask.



  2. Rajjar Says:

    Goodwork guys. Its been a while now, any progress on this topic ? You need any help ?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: