viernes, 18 de mayo de 2018


BTFSS INSTRUCTION  IN ASSEMBLER FOR PIC18F


In this sample, we show that how to use a switch input to make an action.
Remember that I can teach you or help you in your projects. If you interested please ask at:
postgraduatecahg@gmail.com



list p=18f2550
include "P18F2550.INC"
  ;Bits de configuration
        CONFIG FOSC = HS 
        CONFIG PWRT = OFF                  ; Power-up Timer OFF
        CONFIG BOR = OFF                     ; Brown-out OFF
        CONFIG WDT = OFF;
        CONFIG MCLRE = ON
        CONFIG PBADEN = OFF
        CONFIG LVP = OFF
        CONFIG DEBUG = OFF
        CONFIG XINST = OFF
        
; CODE ******************************************************
#define Led PORTB, 4
ORG  0x00
; start from 0x00 address
GOTO START
;jump to start label.
ORG  0x50 ; space for IRS
START
MOVLW 0x0F;
MOVWF TRISA
CLRF  PORTB; PORTB = 0x00
CLRF TRISB;
MOVLW 0x0F;
MOVWF ADCON1
LOOP
BTFSS PORTA,0;skip next instruction if RB0 = 1 
GOTO LEDOFF;    RB0 = 0, 
BSF Led;    LED is on now
BRA LOOP   ; Branch to START
LEDOFF
BCF Led;    LED is OFF.
BRA START
END;END of program.


You can ask by my course in Spanish.






Microcontrollers PIC18F course second sample using assembler


This is the second sample of my course if you interested in the course or you need help in a project (not for free) you can contact me at:
postgraduatecahg@gmail.com



list p=18f2550
  include "P18F2550.INC"
  ;Bits de configuracion
        CONFIG FOSC = HS 
; High speed clock.
        CONFIG MCLRE = OFF                ; Master Clear OFF
        CONFIG BOR = OFF                     ; Brown-out OFF
        CONFIG PWRT = OFF                  ; Power-up Timer OFF
        CONFIG LVP = OFF
        CONFIG XINST = OFF
        CONFIG PBADEN = OFF
        CONFIG CP0 = OFF
        CONFIG CP1 = OFF
        CONFIG CP2 = OFF
        CONFIG CP3 = OFF
        CONFIG CPB = OFF
        CONFIG CPD = OFF
ORG  0x00
; start from 0x00 address
GOTO START
;jump to start label.
ORG  0x50 ; space for IRS
START
movlw 0x0F; 
movwf ADCON1,0 
;PORTAandPORTB pins are digitals
clrf TRISB,0 
;PORT B as an output.
movlw b'00011111';
movwf TRISA,0
;PORT A as input
LOOP
movf  PORTA,W,0  
;Move Port A and store it in W.
andlw  0x0F    
;W = W(AND)00001111
movwf  PORTB,0; 
goto  LOOP; for make a loop
end; END of the program.




Figure 1. Circuit diagram. 


You can ask by my course in Spanish.




jueves, 17 de mayo de 2018





GET STARTED WITH PIC18F2550 PROGRAMMING IN ASSEMBLER AND BIT CONFIGURATION







In this post, I want to share how to write a program in assembler to get started with PIC18F2550 and MPLAB X.

The program can be segmented into 3 parts. The First part is PIC selection through the list and include reserved words.
The second part of the program is the bit configurations.
Finally, the 3rd part of the program is the application program. In this sample, I only get a toggle in the PORT RC0.

Enjoy your first program and please remember that I can teach you or help you with your projects, you can contact me at:
postgraduatecahg@gmail.com





list p=18f2550
include "P18F2550.INC"
   
 CONFIG FOSC = HS ;HS crystal oscilator 8MHz
 CONFIG MCLRE = ON ; enable Master Clear
 CONFIG BOR = OFF ;Brown-out OFF
 CONFIG PWRT = OFF; Power-up Timer OFF
 CONFIG LVP = OFF ;Low-Voltage programming disabled (necessary for debugging) 
 CONFIG WDT = OFF ;disable watchdog timer
 CONFIG PBADEN = OFF ;This is to confing ADC converter check the datasheet
 CONFIG CP0 = OFF ;No code protection  
 CONFIG CP1 = OFF;
 CONFIG CP2 = OFF;
 CONFIG CP3 = OFF;
 CONFIG CPB = OFF;
 CONFIG CPD = OFF;

 ORG 0x00
 GOTO START
 ORG 0x50

 START
    CLRF PORTC ; Clear PORTC.
    CLRF TRISC ; PORTC is confired as outputs.
 MAIN
    BTG PORTC, RC0 ; RC0 Bit toggle.
    GOTO MAIN ; Goto to main address.
    END
 
 

For further information about the bit configuration, you can search in the datasheet and in the next link.

https://openlabpro.com/guide/configuration-bits-for-pic18f4550/





lunes, 30 de abril de 2018




Industry 4.0




I want to start pointing that, it is going to be a reality. I think It's not possible to stop this current. Then Is important to take a moment to think. What will I do about this fact?

From now I do not have the answers but I have more questions?

My work is going to be replaced by a robot or an algorithm?

What can I do better than a robot?

How much time do I have to be prepared for?

Are will be happy with the worst predicted consequences such as government rent to live?

What are my options to be in competition with a robot?

If I am a developer,  can I be replaced by a robot?

I do not have the Answers but, I think the first step is to think and question me what have to do?
Moreover Is important know what are the most important algorithms and how they work to try to predict what a robot can do at least for 5 years in the future.

Now if you think that it is only a science fiction, let me tell you that everybody uses Facebook, Google, and Amazon. They know how you are and what you need. Uber is working in autonomous vehicles and taxi drivers are going to be erased.

I do not interested in getting scared you, I just want to think what do I have to do?.
The most repetitive works are the first to disappear but then the sophisticated jobs can survive such as developers and programmers. (for how time?).

On the other hand, there are not full understood fields such as nanotechnology, solar energy, and quantum computing.  I think new discovers will be needed in the future but again the question is if those discoveries will be done by humans or by robots. Therefore is important to know deeply the contemporary algorithms for IA and try to make predictions. Finally, with that predictions, Actions should be taken.







domingo, 29 de abril de 2018




SPI DAC MCP4921 USING VHDL



In this Post, I want to share the procedure to design an SPI driver for MCP4921 using VHDL. 
If you are interested in the code I can sell it and teach you for only 15 USD.
Contact me at:
postgraduatecahg@gmail.com



Figure 1. Pin terminals of the MCP4921 DAC chip.
Figure 2. SPI timing Protocol for MCP4921.




Figure 3. SPI Driver RTL TOP Design.





Figure 4. SPI Driver architecture.







Figure 5. Simulation of SPI driver.


Video Proof.





Also, We can send analog sine signals by FPGA using Verilog. 



miércoles, 25 de abril de 2018



PS2 protocol implementation for a keyboard using VHDL



This is a sample of my course of FPGAs & VHDL.
If you interested in the complete course or you need help with a project. You can contact me at:
postgraduatecahg@gmail.com



Figure 1. PS2-Keyboard.


Figure 2. PS2 Protocol.



Explanation of the following code.
First is important to note that data is captured approximately every falling edge clock. Thus we use clk'event and clk=0.
Then, this protocol presents an advantage which is that the keyboard sends the clock signal, as a result, we can read a data every clock by a shift register. The frame is composed of 22 bits which are divided into two parts. The first 11 bits are the information and the second 11 bits are the acknowledge byte. The acknowledge byte in hexadecimal format is X"F0", this byte is sent in the second byte if the key is acknowledged. 
Therefore the program evaluates if the second byte is X"F0" and then assign the data byte to leds on my FPGA board as is seen below.
if (clk'event and clk ='1' and data_frame(8 downto 1)= X"F0") then
    leds <= data_frame(19 downto 12);


VHDL Program.
------------------------------------------------------------------------------------------------------------------------

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity keyboard is
    Port ( clk,data: in std_logic;
           leds : out std_logic_vector(7 downto 0));
end keyboard;

architecture keyboard_Architecture of keyboard is
signal data_frame: std_logic_vector(21 downto 0);

begin

process (clk, data, data_frame)
begin
if clk'event and clk ='0' then
    data_frame <= data &  data_frame(21 downto 1);
end if;
end process;


process (clk,data_frame)
begin
if (clk'event and clk ='1' and data_frame(8 downto 1)= X"F0") then
    leds <= data_frame(19 downto 12);  
end if;
end process;

end keyboard_Architecture;





UCF file
------------------------------------------------------------------------------------------------------------------------



NET "clk"      LOC = "R12" | CLOCK_DEDICATED_ROUTE = FALSE;

NET "data"     LOC = "P11" | IOSTANDARD = LVCMOS33 ;

NET "leds<0>"  LOC = "J14" | IOSTANDARD = LVTTL  | DRIVE = 8  | SLEW = SLOW ;
NET "leds<1>"  LOC = "J15" | IOSTANDARD = LVTTL  | DRIVE = 8  | SLEW = SLOW ;
NET "leds<2>"  LOC = "K15" | IOSTANDARD = LVTTL  | DRIVE = 8  | SLEW = SLOW ;
NET "leds<3>"  LOC = "K14" | IOSTANDARD = LVTTL  | DRIVE = 8  | SLEW = SLOW ;
NET "leds<4>"  LOC = "E17" | IOSTANDARD = LVTTL  | DRIVE = 8  | SLEW = SLOW ;
NET "leds<5>"  LOC = "P15" | IOSTANDARD = LVTTL  | DRIVE = 8  | SLEW = SLOW ;
NET "leds<6>"  LOC = "F4"  | IOSTANDARD = LVTTL  | DRIVE = 8  | SLEW = SLOW ;
NET "leds<7>"  LOC = "R4"  | IOSTANDARD = LVTTL  | DRIVE = 8  | SLEW = SLOW ;

miércoles, 11 de abril de 2018


The books used in my VHDL course


If you want to take the course or some help in your problem as a consultant please contact me at:
postgraduatecahg@gmail.com













BTFSS INSTRUCTION  IN ASSEMBLER FOR PIC18F In this sample, we show that how to use a switch input to make an action. Remember that I...