IMSS, UN DERECHO QUE PUEDES PERDER.


En mi caso, y supongo en el caso de unos cuantos más de mis amigos paisanos, mi conocimiento de el sistema público de salud en México es escaso, y, hasta cierto punto, pensé que el IMSS, (Instituto Mexicano del Seguro Social), era un derecho al que cualquier Mexicano podia acceder.

En parte esta idea viene de la educación impartida en la escuela primaria cuando hablan del artículo 4 de la constitución mexicana. ( Art 4: Toda persona tiene derecho a la protección de la salud) (link constitución)

La realidad es que esto es una verdad a medias y en este artículo discutiré lo que he aprendido en los últimos días y mi consejo para otros compatriotas que quieran mantener su estado de derechohabiente.

Para muchos mexicanos, es bien conocido que el IMSS, junto con el ISSSTE, son los servicios de saludo de el estado para atender a la población, y estos a su vez es bien sabido que tienen problemas de solvencia que solo han crecido en los últimos años, impactando la calidad del servicio, deficiencias que se han visto aún más por la actual pandemia del COVID 19. No es raro escuchar bromas del tipo (Inútil Solicitar Servicio, Solo Tramitamos Entierros, ISSSTE).

Pequeño reality check

Algo que seguramente muchos mexicanos descubren muy tarde, es que, a diferencia de lo que el artículo 4 dice, no todos tienen derecho a usar los servicios del sistema de salud (IMSS). En este sentido el IMSS funciona más como una aseguradora que como un servicio de salud universal.

Para poder tener derecho a servicios de salud, uno tiene que estar dado de alta y con una póliza vigente. (La Constancia de Vigencia de Derechos). Puedes validar en cualquier momento el estado de tu póliza aquí. (tramites imss).

Éste es un ejemplo de mi póliza hace unos días, ahi se puede ver que no tenía derecho a servicis de salud.

Condiciones Preexistentes pueden prevenir tu incorporación voluntaria al IMSS.

Éste punto es muy importante y es algo que yo no sabía, si quieres voluntariamente inscribirte al IMSS, tienes que cumplir ciertos requerimientos, incluyendo no tener enfermedades preexistentes, como Tumores (cancer), Insuficiencia Renal, VIH entre otros. Puedes corroborar esto en este link del IMSS. (enfermedades preexistentes IMSS)

Esto al parecer se hace así, para prevenir que uno como mexicano, se inscriba solo cuando esta enfermo, ya que como cualquier seguro de salud, para funcionar correctamente, tiene que tener una cartera de clientes saludables que pague por los servicios de los clientes enfermos. Por desgracia, esta información es omitida de la educación y muchos mexicanos la desconocen.

Hoy en día muchas personas mayores que trabajaron en la informalidad, y que nunca fueron inscritas no pueden gozar de los servicios de salud, y solo se fueron enterando de esto cuando ya estaban enfermos. Más acerca de este problema en este link (Seguro voluntario del IMSS inaccesible para adultos mayores.)

En qué modos puedes inscribirte al IMSS

Por lo que entiendo hasta hoy, hay 4 maneras en las que puedes volverte derecho habiente del IMSS.

1-Alta Patronal: Esta me parece ha de ser la más común en México ya que no depende del individuo, sino de la institución para la que trabajas. Este es el modelo en el que tu empleador paga por tu prestación del IMSS. Este es el modo en el que yo obtuve la mía, en 2014, cuando trabajaba en Oracle. Para este modo no importan las condiciones preexistentes que tengas.

2-Incorporación al seguro de salud familiar: En este casi cualquier mexicano se puede inscribir, sin embargo, si tienes enfermedades preexistentes no lo puedes adquirir.

Ademas, este, a diferencia de el número 1 (Alta Patronal), no cuenta para tus semanas de cotización en IMSS (no cuenta para pensiones ni crédito de vivienda, solo servicios de salud). Más información en esta página del IMSS (Seguro de salud familiar).

3- Incorporación Voluntaria al Régimen Obligatorio: Este es equivalente al Alta patronal, si nunca has cotizado en el IMSS puedes aplicar para esta incorporación, esta, a diferencia del (Seguro de salud familiar) además te permite acumular semanas para pensión y crédito familiar. Dos grandes diferencias que tiene con la (Alta patronal) son.

a)Tu tienes que pagar mes con mes la quota, por que no tienes empleador que lo pague por tí.

b)No lo puedes obtener con enfermedades preexistentes.

De lo demás, funciona igual. Puedes leer las reglas originales en esta página del IMSS. (Incorporación voluntaria al Régimen Obligatorio)

4- Inscripción a la continuación voluntaria al régimen obligatorio: Este es equivalente al punto 3, con dos grandes diferencias.

a) Solo puedes aplicar para este si ya habías cotizado anteriormente en el modo (Alta patronal) y no han pasado mas de 5 años desde que te diste de baja (renunciaste o fuiste despedido) y cotizaste al menos 52 semanas en los 5 años anteriores a que fueras dado de baja por tu último empleador. (artículo de cotizar en IMSS si perdiste tu empleo)

b)Si cumples el puto a), puedes obtenerlo aun con enfermedades preexistentes, a diferencia del modo 3.

Esta 4ta modalidad es interesante por que parece ser la única opción para obtener IMSS si quieres trabajar independiente y tienes enfermedades preexistentes. Más información de esta modalidad del IMSS aquí. (Inscripción a la continuación voluntaria al régimen obligatorio)

Me puedo inscribir en linea o tengo que ir al IMSS?

Parece ser que para los modos 2,3 y 4, puedes hacerlo en linea a traves de este portal. (tramites imss).

Como hago los pagos

Una vez que estés inscrito te va a llegar una ficha de pago como esta. Esta se puede pagar en ventanilla de cualquier banco en México, o por medio de banca en linea de algunos bancos, por el momento se que la banca en linea de Banamex no permite pagarlos, pero la banca en linea de Bancomer sí. El problema es el tipo de ficha, SIPARE. Aquí info de SIPARE bancomer(SIPARE bancomer).

Si tengo Enfermedades preexistentes ya no puedo tener IMSS?

Esto depende de algunos factores como he explicado en los puntos anteriores. Pero se resume así.

1- Si estas inscrito y activo en el IMSS no lo perderás mientras sigas trabajando con un empleador formal o mientras lo sigas pagando.

2- Si tienes enfermedades preexistentes pero cumples el punto a) del modo 4 (Inscripción a la continuación voluntaria al régimen obligatorio). puedes recuperar tu afiliación al IMSS de manera voluntaria.

3- Si consigues un trabajo formal, que te de prestación de IMSS seras automáticamente afiliado por las cuotas de tu patrón.

Por desgracia, si tienes enfermedades preexistentes y no caes en alguno de los tres casos anteriores, probablemente no podrás alistarte.

Más vale prevenIMSS

La moraleja de la historia es la misma que con cualquier seguro, vuélvete derecho habiente antes de que envejezcas y te enfermes. Incluso sin trabajo formal, te puedes inscribir si estas sano y pagar tus cuotas voluntariamente.

El CACAS aka (AMLO) dijo que con el INSABI todo va a ser gratis.

El INSABI y Seguro popular son instituciones separadas del IMSS pero las mencionaré brevemente.

Como habrás escuchado en las noticias, AMLO creo el INSABI (Instituto de Salud para el Bienestar).

El INSABI sustituye al Seguro popular, y algunas de las diferencias con el seguro popular son estas.

1- El seguro popular tenía cuotas anuales, basadas en tu estrato socioeconómico. el INSABI, no, es completamente gratuito.

2- El Seguro popular cubría los niveles 1 y 2 de salud, y algunas enfermedades de nivel 3 (especialidades). el INSABI no cubre nada de nivel 3. Esto significa el INSABI no cubrirá, por ejemplo, enfermedades (prenatales, neonatos, varios tipos de cancer, varias enfermedades respiratorias y de sangre entre otras), que sí cubría el Seguro Popular. Más información acerca de los( tres niveles de salud en México). Más información acerca de las (diferencias de cobertura de INSABI y Seguro popular.)

Página oficial INSABI

El INSABI es un instituto nuevo, no se mucho de como se vaya a comportar en el futuro, pero por ahora, a mí parecer, tiene un futuro incierto.

Vivo en otro país, que debo hacer con el IMSS?

Si planeas nunca jamás volver, puede que no te tengas que preocupar por lo que pase con tu IMSS, pues puede que nunca lo utilices. Pero si un día planeas regresar, entonces yo recomendaría que vieras si puedes habilitar tu estado de manera voluntaria y que pagaras las cuotas correspondientes. Los trámites de inscripción voluntaria son abiertos para cualquier Mexicano sin importar en qué parte del mundo estés.

Vale la pena el IMSS? todos dicen que es muy malo.

El IMSS, como toda institución en México, no es perfecta, y ha pasado por varias reformas para mejorar su servicio y estado financiero. A pesar de sus problemas, sigue siendo el único medio de saludo para muchos mexicanos (el IMSS atiende a 6 de cada 10 mexicanos), ya que sigue siendo más barato y más permisivo que las opciones privadas. Inscribirse al IMSS de manera voluntaria no solo te permitirá a ti gozar de sus servicios en un futuro, sino que también ayudará a que se pueda prestar mejor servicio a la gente que actualmente depende de él.

LINKS

http://www.diputados.gob.mx/servicios/datorele/cmprtvs/iniciativas/Inic/136/2.htm#:~:text=Toda%20persona%20tiene%20derecho%20a%20la%20protecci%C3%B3n%20de%20la%20salud.

https://serviciosdigitales.imss.gob.mx/portal-ciudadano-web-externo/home/validar

https://www.animalpolitico.com/2017/11/imss-seguro-voluntario-adultos/

http://www.imss.gob.mx/derechoH/enfermedad-seguros-familia

http://www.imss.gob.mx/tramites/imss02030c

http://www.imss.gob.mx/tramites/imss02007

https://www.bbva.mx/personas/servicios-digitales/pago-de-impuestos/sipare.html

https://www.paho.org/mex/index.php?option=com_content&view=article&id=218:respuesta-sector-salud&Itemid=387

https://www.lja.mx/2020/01/66-enfermedades-dejaran-de-ser-gratuitas-en-el-insabi

https://www.gob.mx/insabi

http://www.imss.gob.mx/prensa/archivo/201807/191#:~:text=El%20Director%20General%20del%20Instituto,aumento%20de%20estudiantes%20y%20familias

https://businessinsider.mx/cotizacion-imss-como-seguir-cotizando-imss-perdi-trabajo/



thanks and Rest in peace FLASh

In every story, there is a point in time that sets a path in your life. In mine was in my puberty, set by a middle school teacher and was very brief.

Since elementary school we would always have some computer class around, in my case they would teach us to use word and those things. and then we would play random games. So was in my first year in middle school, nothing too exiting. By my second year in middle school they changed the computing class teacher, I vaguely remember due to some scandal. The new teacher was probably around 28 or 30, and he did tried to show us more than just word. so we started second year with HTML. again nothing more exiting than <marquee> lololol </marquee> .

However by 3th semester he taught us to use macromedia flash MX. Simple things, make animations and setup buttons. I remember the intro class was he showing us the capabilities of flash, he showed us a 3D video of a singing monster that was in no way made in flash but that is what he said and I believe him. Other whole class was learning the 4 stages of buttons, (Up, Over, Down, Hit), that was a hard one . Good times.

The final project of the year was to make an animation and, I don’t remember exactly how, he mentioned we would get a copy of the software by the end of the year, that was, if we made a good work. So then I used to go to the computer lab at lunch time to work on my animation. which was just a pool table with marbles rolling. I know, very lame haha. Is not that I started with that. I wanted to do a story of something but turns out drawing was not my strong point.

So let be it. I finished my pool table animation, and I got a copy of the software. Don’t ask me about the legitimacy of it. I hope is enough to say that later when I had money I did got a legit one.

Back at home, I started playing with the software on my own, making more animations. I used to find the form transformation interpolation fascinating, and I realized you could put music into it so I tried to make music videos. Kind of karaoke ones that have the letters dancing and morphing and moving. they were very cool. However my computer was rather slow, so they would go out of sync very quickly. Oh well.

Then I entered High School, there there was also a computing class, and again first semester was office and boring stuff. However at that point I realized that many of the games that I played in middle school in the computer class were actually flash games. so I got fixated on trying to figure out how to make them. So I started learning AS2. I know so old. but hey, it was easy.

I would make small animations and have small pieces of code here and there to manage events. At the time you could put random code almost anywhere. It sounds horrifying to today’s me, but back then it was cool.

There I did learn to program, with bad coding practices. learned the basic elements, (if, else, for) and the main loop function. I made a pacman game with AI (rudimentary) ghost and everything with only those, no functions. It was a lot of duplicated code. but it worked….. and consumed the whole processing time of the core so you better have a dual core.

Then by the end of programing pacman I learned about functions and refactored some parts. performance didn’t improve but there was a slightly smaller piece of crappy code.

Then I entered colleague and of course decided to pursue a BS in computer science. We started learning java, and the first classes were kind of easy since they would teach us again, (if else for) and functions, all of whom I was already able to craft into poorly written blobs of code, so, no big deal there.

Also by that time I got my hands into Flash 8, which came with AS3. coming from AS2 it was whole different thing. No more duck typing… Or at least less duck typing.

In colleague I did improve my flash programming skills. and my programming in general. And I would use flash in a lot of projects for school. In Flash it was relatively easy to handle graphics and would always have this wow effect compared to projects running on console. I also made several games there. mostly ripofs of something else, made a galaxian, mine sweeper, pong, and attempted to do racing and RPG games. At that time I remember there were some very impressive 3D racing games in flash and some very beautiful art projects on the internet.

Also by the middle of my undergraduate studies I got a small job making flash games, It was awesome, I would make like 400 USD a moth but for me that was cool, didn’t last long tho. The owner of the company disappeared after two months.

By that time, Steve Jobs declare war against flash, saying HTML was the future. At the time I find it hard to believe since everything ran on flash.

After that I interviewed for an internship at MSFT, didn’t made it but a friend of mine did, so I felt a bit sad and started to look for a part time job for the summer. Interestingly I found it in the news paper( I know, old school ), there were looking for flash developer as freelancer.

With that company I made 3 flash projects. they where Interactive disks for kids that where shipped with books, like math and grammar kind of things. I really enjoyed making those things. They would pay me like 1600USD to 2200 USD per project and it would take me like 4 months to make each. For me that was very good money, at the time my father would give me a monthly allowance of 120 USD so you make the math. It was at that point when I finally was able to afford my license. so I got Flash CS5 for 700 USD and I was happy. After all those years I finally had a legit version of this thing and I was really grateful at that time.

By the end of colleague I did got an internship at MSFT which was ok, I got to know Redmond and Seattle which was very cool, however I did not get the FT offer. I guess that is why was it just ok and not great, anyway. Back in Mexico I finally graduated and started to interview for full time jobs. Also, this was 2012, and the war against flash was heating up. I think was in that year that the fate of flash was finally wrote down. even tho it would take several years for it to go away.

In the meantime I started making the FABLE tool. Which was a box2d level editor, this time it was made in Adobe air and flex. Which really means, more flash and AS3. I spent 1 year solely making that tool and then I got hired at Oracle in Mexico. While at oracle I kept working on this tool and even got to used to make some OS books for kids.

That FABLE tool was probably my biggest project in flash and the last one, containing 60k lines of AS3. Then in 2016 I got a hired as FTE at MSFT in Redmond and stop development of the tool. I always intended to take it back and improve and implement a lot of cool features I had in mind but time passed and came January first 2020. Flash is dead, and adobe air and flex on life support. my project is pretty much obsolete, and yet , is hard to say good bye.

For me was probably a 17 years ride, along flash, learning, dreaming, and enjoying programing. I will miss their out of the box approach, that had everything working from start and the fact that you could mix and match animation, code and images in such a seamless way. Its reduced set of graphic capabilities with its reduced set of coding capabilities made it a nice playground for teenage me, and its evolution thru AS3, OOP, Air and FLEX made it a great tutor as I grew up. I have the feeling of flash being and old friend that grew with me and now has to say good bye. And is a bit sad to see him leave.

For excercises

TIK TOK CHINA exercise.

Create a JS program that gets a number from the user and then print the numbers from 0 to the number provided by the user and do the following calcuations.

1- if the number is divisible by 3 it should print TIK instead of the number.

2- If the number is divisible by 5 it should print TOK instead of the number.

3- If the number is divisible by 3 and 5 it should print CHINA instead of the number.

4- Use prompt to get the value from the user.

5- Use console.log to print the output to the console.

Examples of when user inputs 20

1
2
TIK
4
TOK
TIK
7
8
TIK
TOK
11
TIK
13
14
CHINA
16
17
TIK
19
TOK

2 cristmas tree

Write a program that receives a value from a user using prompt and draw a christmas tree using * and spaces with the same level of lines as the number inserted by the user.

Example when user inputs 5

    *
   ***
  *****
 *******
*********

3 Enigma machine

Create a program that can encrypt messages using the following rules

1-The program should ask if it needs to encrypt or decrypt

2- the program will receive a phrase in english in lower case

3. the program should replace the letters as follows table, (depending if is encrypting or decrypting.

4 any other character should remain unchanged.

q — aw — be — cr — dt — ey — f
u — g i — ho — ip — ja — ks — l
d — mf — ng — oh — pj — qk — r
l — sz — tx — uc — vv — wb — x
n — ym — z

example, if the program receives the string “cat” it should return “vke“. when encrypting

In the same way, if the program gets the string ‘vke’, it should return ‘cat’ if decrypting

NOTES:

if you have a variable string

var str = “hello”

you can get characters at specific part of the string with

str.charAt(2)

you can get the length of the string with

str.length

4 Roman Nightmare

Make a program that translates a number provided by the user between 1 and 399 and translates it to roman numbers.

Example when inserting 7 output should be VII

Example when inserting 399 output should be CCCXCIX

Example when inserting 159 output should be CLIX

Notes:, in roman numbers the following equivalences hold true

I = 1

V = 5

X = 10

L = 50

C = 100

III = 3

XXX = 30

III = 300

for loop basics

A for loop allows to execute a piece of code several times.

Example 1.0

for(var i =0; i<10; i++)
{
    console.log("I am printing this message 10 times");
}

If the previous code where to run in chrome we could see the following output in the console.

Basic structure of for loop

for(    INITIALIZATION     ;     CONDITION     ;    INCREMENT    )
{
           CODE
}

We have 4 main parts that build the for

  • INITIALIZATION: Executed only one time at all.
  • CONDITION: Executed before the code is executed. (executed several times)
  • CODE: Executed only if CONDITION is meet (executed several times)
  • INCREMENT: Executed after the code is executed. (executed several times)

The following diagram shows how the flow of a for is performed.

so in our original example 1.0 we could spread the parts of the for as follows.

for(var i =0; i<10; i++)
{
    console.log("I am printing this message 10 times");
}

NOTE THAT

  • INITIALIZATION executes only once.
  • the CONDITION will be executed as long as it is meet.
  • Every time the CONDITION is meet, the CODE and the INCREMENT will execute once.

Divoom Tivoo IC components (part 1)

Here we will discuss the electronic components that compose the circuit board of the Tivoo, in this first part we will just find what the components are and what they do.

Lets start with the screen

Tivoo screen back

Here we can see three main IC of the board

ICN2053 – 16-channel PWM

CHIPONE ICN2053BPA13115BB

Here you can see a link to this IC
http://www.xlix.ru/datasheet/ICN2053.pdf

ICN2012

CHIPONE ICN2012A9092EBF

Here you can see a link to this IC
http://wiki.amperka.ru/_media/%D0%BF%D1%80%D0%BE%D0%B4%D1%83%D0%BA%D1%82%D1%8B:rgb-led-matrix-64×32:icn2012_datasheet.pdf

This is basically a merge between TTL 74HC138 and 8 powermosftets.

F130G4 0 Microcontroller

F130G4CE80879AJ1746

Here you can see a link to what I think this IC is.
https://datasheetspdf.com/parts/GD32F130G4U6.pdf?id=976678

This IC is aparently from a company called GigaDevice, the IC have diferent naming, so may be a clone, Seems this IC was originally a GD32F130G4 from GigaDevice, the Die match at least in the shape. Also the logo looks like GigaDevice, I may be wrong tho.

Now lets jump to the Main board.

main board front Tivoo
main board front 2 Tivoo

Main board back Tivoo

This board have 5 major IC

XB8608A 8u1 – Lithium Battery Protection IC

XB8606A8u1

Here you can see a link of what I think is this IC
https://datasheet4u.com/datasheet-parts/XB8686E-datasheet.php?id=1243989

This IC seems to be a Once Cell Lithium-ion Protection circuit. The original IC seems to have been XB8686E from Sysemi I presume is similar to that link since the numbers kind of match and the way it is installed relates to the pdf. you can see the top 4 legs are unused, or in this case, maybe connected to the negative part of the battery altogether.

25Q127CSIG – Flash memory

AJ183025Q127CSIGU8A252

Here you can see a link to what I think is this IC
https://www.digikey.com/product-detail/en/gigadevice-semiconductor-hk-limited/GD25Q127CSIGR/1970-1027-1-ND/9484777

This IC seems to be Flash memory, the original IC seems to be GD25Q127CSIG

CS8326S B144 – Audio Amplifier

CS8326SB144

Here you can see a link of what I think this IC is
https://datasheetspdf.com/datasheet/CS8326S.html

FP8102 SAe-00L Li-Ion Battery Charger

FP8102Sae-00L

Here you can see a link to this IC
https://datasheetspdf.com/datasheet/FP8102.html

ANYKA AK1052DN048 GZSH04I18 Microcontroler/DSP

ANYKA AK1052DN048GZSH04I18

Here you can see a link to this IC
https://datasheet.lcsc.com/szlcsc/1904091402_NYKA-AK1052D_C383433.pdf

We will discuss the function of each of this ics in future post.

DIVOOM tIVO dISASEMBLY (teardown)

This Post will show my disassembly process as well as screenshot of main components and tips and tricks.

The main structure of the Tivoo is not glued, it consist of some snap locks and screws.

The first step is to remove the knobs, there are two knobs in the unit, those you just need to pull with a bit of force and they will slide of, they are held in place only by pressure and friction so very safe to remove.

Second step is to remove the plastic faceplate. This is the trickiest part, as the face plate is attached with latches.

In the next picture I highlighted the latches.

Tivoo Latches

To start disassembling the device, I started from the knob corner moving up using a guittar pick.

Using guitar pick to remove faceplate.

Once the faceplate is removed, the tivoo looks like this.

Tivoo without faceplate

After that the tivo screen is composed of 4 components.

*Glass
*Diffuser panel
*ligth mask
*led array

The following images is the device after removing the Glass

Tivoo without Glass

The following image is the device after removing the diffuser

Tivoo without deffuser

The following image is the device without the grid mask.

Tivoo without grid mask.

Here are the images of all the 4 components of the screen.

Tivoo glass, diffuser, mask and led display.

Here is other shot of the LED display turned off.

Tivoo LED display

To continue the disassembly process, we need to remove some 6 screws pointed in the next screenshot.

from this point the screen is just held in place by friction against some panne like material. to extract the screen I used one screw driver in one of the holes and pulled as follows.

removing led screen from Tivoo

After that you can just unplug the two wires, the big one is power and data, the small one is the microphone.

screen connected to Tivoo

Here is another picture of the main board of the screen. (The following picture is highRes so you can see the components.

In the case you can see the main battery (a lithium 18650 w 3000mah), the speaker and another board behind the battery (hard to see). You will also see other two screws that need to be removed to continue with the disassembly.

Screws inside assembly.

After that you can remove the inner assembly from the outer case.

Tivoo inner assembly and outer case.

Now to open the inner assembly you need to remove itehr 4 screws.

Inner assembly Tivoo screws

After that you will need to remove other three screws that attach the circuit boar to the assembly and unglue the battery.

To Remove the battery I just gently moved until the glue broke. Also note that the board itself have some of the same glue, so you will need to pull it gently until the glue gives up after removing the 3 screws from the picture.

Tivoo main board srews

Here you can see the board separated from the assembly.

main board Tivoo apart.

Next Here I add some high resolutions from the front and back of the circuit board.

Front side of board
back side of board.

That will be all in this entry, thanks

Note: to see high res in your phone you may need to switch to desktop site mode.

Divoom Tivoo Retro Non Destructive INSIGHTS

For Black Friday I ordered a Divoom Tivo, since I think the pixel art on it looks so cool. And also to learn about the workings of this little neat device.

Divoom Tivo Inside box

The device itself is very nice.

Tivo showing Mario Pixel Art

The grid of the screen is a 16×16 pixels, and the whole screen measures 579×509. you can see a mock of the configuration in the following sketch.

Mock of Tivo

The values in the above image are my measures with caliper and may be a bit of and the may not even add, but they give a nice approximation. (good enough for me at least).

GAL16V8 :3- 4 bit counter using macrocell

We will construct a 4 bit counter using the GAL16V8, but instead of constructing the latch like in the previous post, LATCHES, SR LATCH. we will use the builtin flip flop of the MACROCELL.

As a quick reference, a D type flip flop is a device that can store one value, like the SR LATCH, however the value will only be stored on the rising edge of the clock. In reality it does the change using both the rising and falling edge of the clock. You can have a deeper insight of its works with this video from Ben Eater. https://www.youtube.com/watch?v=rXHSB5w7CyE

When configuring a macrocell you need to describe the equations which based in the current state, will change the next state.

When configuring the D-Latch you need to think on how the next state will be reached based on the current state. We can think of it as current state, Q and next state QNext.

In a 1 bit binary counter, when Q is 0, the next state is 1. and when Q is 1, we overflow and the next state is 0. Making it effectively that QNext is !Q, such equation would look like this.

QNext = !Q;

Lets see what would be the truth table for this 1 bit counter.

QQ Next
01
10

Now, the second less significant bit, Q2, will have its next state based on two values, the value of Q and the value of Q2. For the rest of the examples we will call Q as Q1.

The first condition of Q2 is that it will change every time Q1 transitions from 1 to 0, or effectively, every time !Q1.

We can see that in the following truth table.

Q2Q1Q2NextQ1Next
0001
0110
1011
1100

Q2Next = (Q2 and !Q1) or (!Q2 and Q1)

In colloquial language this could be expressed as the following quote.

If Q1 is true, Q2Next will be complement of Q2, if Q1 is false, Q2 don’t change.

Now, the way to write this code in CUPL, to be able to progaram with our gal will be very similar, however CUPL does not have a QNext, instead it have a Q.d where d stands for DLatch. So our equation in CUPL will be like this for Q1 and Q2.

Q2.d = (!Q1 & Q0) # (Q1 & !Q0);
Q1.d = !Q0; 

We can follow the same analysis for the other 2 bits. If we decide to do so we could get a CUPL code similar to this one. This code also includes a clr input, to reset the counter to 0 at any time.

Name  CCCCCC;
 Partno XXXXXX;
 Date XX/XX/XX;
 Revision XX;
 Designer XXXXXX;
 Company XXXXXX;
 Assembly XXXXXX;
 Location XXXXXX;
 Device g16v8ms
 PIN 1 = clk;
 PIN 2 = clr;
 PIN 15 = Q0;
 PIN 14 = Q1;
 PIN 13 = Q2;
 PIN 12 = Q3;
 Q3.d = !clr & ((!Q3 & Q2 & Q1 & Q0) # (Q3 & !(Q2 & Q1 & Q0)));
 Q2.d = !clr & ((!Q2 & Q1 & Q0) # (Q2 & !(Q1 & Q0)));
 Q1.d = !clr & (!Q1 & Q0 # Q1 & !Q0);
 Q0.d = !clr & !Q0;

This would be the wiring diagram.

4 bit counter from aruduino

The clock is being generated by an arduino, but it could be generated by any means, including a 555 timer as long as is a square wave between 0 and 5 volts. (for this circuit that is being powered by 5V).

Also here we can see the the circuit assembled in action, I added a small yellow led to see the state of the clock.

GAL16V8 :2- Latches, SR Latch

Today we will explore the basic of SR Latch and how to build one with a GAL16V8.

The wikipedia definition of a latch is ” a circuit that has two stable states and can be used to store state information“.

The latch we want to implement today is the SR LATCH with two nor gates. the circuit is as follows.

Image result for sr latch

This latch have two inputs, Set (S) and Reset (r), and two exits, Q, which is the stored state, and !Q, which is the inverse of the stored state. Easy.

The truth table of this circuit is as follows.

Truth table of SD Latch

As we can see, as long as only one of either Set or Reset is on, the Q output will store the value of Set.

Note that when Set and Reset are off, Q and !Q keep their values, that is where the storage property comes in.
Also in this specific latch made out of NOR gates, when both Set and Reset are ON both Q and !Q are disabled, thus both are 0, this is an unstable state and the end value of Q and !Q when both Set and Reset are OFF again will be a race condition on which one is set last.

Now How will this looks in CUPL code? Well, we only need to define the following two equations.

Q = !(R # QN);
QN = !(S # Q);

As you can see, we are only describing the inputs of the NOR gates here, in the CUPL file it will look similar to this.

Name SRLATCH;
partNo 00;
Date 16/06/2016;
Revision 01;
Designer Esteban;
Company estebon;
Assembly None;
Location None;
Device g16v8ms;

PIN 2 = R;
PIN 3 = S;

PIN 12 = Q;
PIN 13 = QN;

Q = !(R # QN);
QN = !(S # Q);

Now we burn our gal and wire as follows. See the Make it blink tutorial on how to program our gal.

Wiring of SR Latch

And finally we can test it, Notice how the output led match the button pressed.

SR Latch with GAL16V8

That is all on this, hope you find it useful.