Archive for MikroBasic

StrobLED, a quartz controlled LED stroboscopic light for turntables

First, I know my english is not perfect. If you want to contribute sending me a better redaction, you’re welcome to send.


One week ago, in the TNT-audioaddicts group from Yahoo! groups, an user started a thread about building an strobe for his turntable. There was discussed the fact that neons that turntables brings light twice every mains cycle (the + and聽 – of it ). The person started it offered as a solution for this using 2 leds each polarized in one way. This has some problems:

  • you need a low voltage output for AC, (you can get it from transformer if available)
  • If the mains frecuency has an error (ie. 1 hz) and your turntable mount a synchronous, then the error will be in both strobe flash and plate speed, so, when the speed seems be adjusted, you’ll have that error (the mains frecuency error).

I proposed the built of a led+microcontroller-quartz controlled strobe light source, and here it is.

I’ve used two tools for developing this and both can be obtained free of charge with enough features for this project (limited versions but not time limited):

Also, you’ll need a programmer for the PIC, if you have one or know anybody has one use it, if you can’t get one, search the web for an easy to build-cheap one. There are lots of designs in the Internet, just search for one you like. For example search for JDM programmer, and build the one you like (but be sure it programs the PIC12F629!). For programming the PIC you can use Winpic800 or ICProg.

The circuit is very simple, just the PIC, the power it need to work, the MCLR supply (this doesn’t have a reset button), a jumper to select 50/60 Hz simulation, and the LED. It can be powered for anything between 3V and 5V, but beware, the current limiting resistor for the LED is calculated for 3V, see below to calculate the value if you want to use an higher voltage.

Notes about the LED:

  • You can use the LED you like (hey! up to 25 mA), this design is calculated to use only ONE LED, because the PIC can draw only current for one (25mA max.).
  • The current limiting resistor (R1) is calculated for 3V, see below to calculate it for higher voltage.
  • If you think is better use more than one led, we have the option of drive them by a transistor. Tell me if you think is this is interesting for you and i’ll do a new design with it.

The schematic:

As i said before the schematic for StrobLED is pretty simple, only complicated 馃榾 by the use of the quartz crystal, but as we need precision for this is better use it instead the built-in oscillator. I’m using 8Mhz instead 4Mhz to get more control over the delays used to blink the LED, i’m using 8Mhz instead 20Mhz to save power if you use batteries.


This is simple:

  • Q1, C1 & C2 are the oscillator.
  • R1 is the current limiting resistor for the LED (LED1).
  • R2 is a limiting resistor to bring MCLR high (if you bring this low (to GND) then the microcontroller resets itself, but this is not needed here)
  • JP1 is the jumper to select the frecuency operation (open= 50Hz, closed=60Hz)
  • NOTE: in this design GND=VSS, i’ll fix when finish this post.

The PCB:

NOTE I’VE NOT BUILD THE PCB for now, it may be wrong, i’ve test the StrobLED in a breadboard. If you have doubts don’t build it until i remove this warning.

This is a little one (could be smaller using SMD components, but complicated to mount!). I think this size can be installed in any place in your turntable (if you want to do that) or in a little box+2AA batteries and use 芦by hand禄.

The PCB with components placed:


And the routes:


Later i’ll post both schemas and PCB in Eagle format and PCB in PDF also.

PCB Update.

As the previous PCB has very narrow traces, it may be difficult to make it for a hobbyst, so i’ve make another PCB design with thicker ones and built it with a CNC Mill. Here it is:


The V.2 Layout:


The V.2 PCB:


V.2 Component side:


Finally i assembled the StrobLED in the PCB above.

Here is a picture of it with the Hz jumper installed (then it would run at 120 Hz, so it simulates 60Hz AC)


The oscillator performs very well. Here is running at 100(50)Hz. (Click the image to see full size).


Also running at 120(60)Hz. (Click the image to see full size).


How it works with an strobe disc? Well as my Revolver turntable has not an Strobe (nor adjustements), i only can cut a Vinyl Engine one and take a picture (long exposure) to show it works: (Click to enlarge).


The code:

The code is writed in MikroBasic and now i’ll post it later (must cleanup it 馃檪 and add the frequency routine (now it works at fixed 50Hz))

Calculating R1

The R1 resistor is placed to limit the current throw LED1 and of course the pin GPIO of the microcontroller. If you change the LED and/or the power supply voltage, you must recalculate its value, but don’t be scared, is very simple.

By Ohm’s law, the current throw a circuit is the same in all, and it is R=V/I (R in ohms, V in volts, I in amps), then you must calculate R to limit the current throw this way:

Imagine you decide to use a LED that has a forward voltage of 1.9V and a forward current of 20mA, look no more: is this one.

Imagine also you decide also power StrobLED with 4.5V instead 3V (ie. 3xAA batteries).

The calculation is:

R=V (4.5-1.9)/A (0.02)

You must substract from voltage, the voltage drop of the led (AKA forward voltage), and we passed mA to A (by dividing by 1000) so R:

R=2.6/0.02 = 130 ohm

The nearest commercial (by up) value is 150 ohm, so choose it. To calculate the disipated power (and resistor power) the formula to use is W=V*A, being V=The diference between power supply voltage and LED drop (2.6 as we calculated before) and A is the current throw it (remember, the same in all the circuit):

W=2.6*0.02= 0.052W, so a 0.25W (1/4 W) resistor will be enough.

For this LED and using the StrobLED with 4.5V you must replace R1 with a 150 ohm, 1/4W resistor.

Will continue….

If your turntable hasn’t a strobe disk just get one from Vinyl Engine, print it, carefully cut it, more carefully make the center hole, and you’re done!

Creative Commons License
StrobLED by Jose Maria Terry is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
Permissions beyond the scope of this license may be available at

Deja un comentario

Empezando con interrupciones en PIC con MikroBasic.

En jvm-bots publican un ejemplo de parpadeo de 2 leds, uno controlado en el bucle principal del programa y otro mediante la interrupci贸n de TMR0. Leetelo si quieres empezar a trabajar con timers o interrupciones.

Deja un comentario

Creando PWM por software en PIC con MikroBasic.

Si quieres generar se帽ales PWM en un microcontrolador que no tiene salidas para ello (o necesitas mas de las que proporciona), puedes hacerlo por programa, en jvm-bots encontramos un ejemplo totalmente desarrollado.

Deja un comentario

Leyendo codigos IR con PIC

Si quieres aprender a leer los c贸digos que transmiten los mandos a distancia por Infrarojos, puedes empezar por aqui. Este ejemplo lee el protocolo NEC, en MikroBasic pero f谩cilmente adaptable a cualquier lenguaje.

Deja un comentario

Ejemplitos de MikroBasic y Proteus.

Ejemplitos es como se llama este hilo en todopic. Y de eso trata, de ejemplitos con c贸digo MikroBasic y su simulaci贸n en Proteus. Date una vuelta por ah铆 si quieres aprender MikroBasic para PIC.

Deja un comentario

Empezando con MikroBasic

Si est谩s empezando con MikroBasic, todopic tiene un hilo en sus foros de ayuda para empezar con este lenguaje.

Deja un comentario