Jan 31

My view on… Erasmus @ Group T

Note: This was the situation in early 2012, since then Group T has improved the whole process a bit.

As the minister of Education is aiming to get at least 1/4 students out on an Erasmus experience, let’s take a closer look at how things are handled at Group T. From my point of view that is. I’m not going to discuss coming to Group T as a non-Belgian student, just the other way around, as a Group T Electronics-ICT student going abroad.

As noted on the Group T website there are several semesters you can choose from, being in my 3rd bachelor year and having a friend who was considering it I thought it’d be a cool experience to have as well. Judging from the blog and photos of my stepbrother, it sure is. Anyway, we checked out the listed partner universities, too bad the information is insufficient and rarely updated.

We started out by selecting some universities we thought were pretty good, such as the ones in Finland and the UK. Sadly the Finnish one almost had no English courses and attending classes taught in Finnish wasn’t going to work. Rejoice when we found a lot of matching courses in England! When we decided to go ask the Erasmus coordinator at Group T, she informed us the agreement was only for the chemistry department (why isn’t this information on the website?). Onto Denmark, no luck either, after pushing to call the university it appears they do not accept any more Erasmus students. The search continued..

Matching courses is quite a bit of work, we had a couple of universities that would do, however none of them seemed to be eager to accept Group T Erasmus folks. At the moment we asked to contact the university my stepbrother is at, though enthusiastic, the coordinator didn’t call right away, which I think would give an answer a lot faster than ‘waiting a week for them to respond to my email’.

I think it’s kinda unfortunate Group T profiles itself as an ‘International University College’ though going on Erasmus as a Belgian student (at least when you’re in the Electronics department) is a huge struggle to even get one university you can go to. We’ve been trying for over a month now and without any luck. It seems most of the partners do not have matching courses for the Electronics master.

First of all they should put a LOT more work into the Erasmus section of the website, add more useful, correct, accurate and important information. There are just a couple of Electronics students that applied, a couple being less than five! I’m starting to think quite a lot of people just give up after spending hours on trying to get a program together which is shot down soon after.

That being said, the professors are very helpful on the other hand. The Electronics department director tried his best to help us and some of the professors we asked were prepared to take a look at courses of other universities to see if they matched with theirs.

In the end I think Group T still has a long way to go if it truly wants to be ‘International’, at least for its native students. Promotion for this is rarely seen, only after we asked about it they put a small news post on the Group T site linking to the (outdated) Erasmus page.

I’d love to hear other Group T students and their experience with applying for an Erasmus semester as well as the story of people who returned after being away for a semester. I’m sure if more people would blog about it, or even talk about it, more students would be interested and hopefully more effort would be put into the whole program. But there are no testimonies to be found (do link me to them if you come across them though).

We’ve been waiting for about a week for a reply from Sweden but no luck yet, it seems chances for a semester abroad are slimming by every passing day.

Update July 2012: Managed to get accepted into Politecnico di Torino, check the Erasmus tab at the top of the site to see more information.

Dec 17

PIC18F2550 Assembly Tutorial 3

In this tutorial we’ll continue with the serial communication between 2 microcontrollers. You should always configure one PIC as master while all the others are to be configured as slaves. For more information check this SPI explanation.

SPI Master-Slave Configuration

SPI Master-Slave Configuration

Check the datasheet to see which pins are SDO (output), SDI (input) and SCK (SPI Clock). Once you have connected the PICs there are a couple of registers that need to be set.

This is for the master:

MOVLW	0x00	; Datasample middle, SCK act-idle.
MOVLW	0x32	; SSP enabled, Idle at high, Fosc/64

As you can see we use the internal timing components for the SPI clock, however you can opt to use TMR2 as well. Don’t forget to enable TMR2 and set its T2CON register if you do this.

This is for the slave:

MOVLW	0x00	; Datasample middle, SCK act-idle.
MOVLW	0x35	; SSP enabled, Idle at high, SPI SLAVEMODE

Make sure you don’t make a mistake here, if you have your CLK idle at high, see to it that the transition is configured correctly else you’ll miss the first pulse. For example, when the CLK is idle at high, its first pulse will be from high to low. When you configure the slave that it should do something when the CLK goes from low to high you will have missed that first pulse resulting in missed or incorrect data.

Now you have configured both master and slave you can send any data you wish. Let’s take a look on how to transmit data from master to slave:

   goto	Main                    ; Infinite loop
   bcf		PIR1,ADIF	; Clear AD converter flag
   MOVFF	ADRESH,SSPBUF	; move ADRESH to send buffer
   bcf		PIR1,SSPIF      ; Clear the flag
   MOVFF	SSPBUF,PORTB    ; Move received data to PORTB
inter				; using single interrupt priority
   BTFSC	PIR1,SSPIF	; if set-> transmission finished
   CALL	SPIread
   BTFSC	PIR1,ADIF	; wait until AD finished -> send
   CALL	SPIsend

In this example I’m sending values sampled by the AD converter to the slave. The code is pretty self explanatory. The ADC will generate an interrupt when it’s finished with converting and the SPI will generate one when it’s done transmitting the data that was in SSPBUF, which is the send buffer.

The slave has even simpler code:

   goto main
   bcf 	  PIR1,SSPIF
   movff  SSPBUF,PORTA
   CALL   SPIread			

The slave will generate an interrupt when the data byte is received, you just have to move the data in the buffer to another register such as PORTA if you’d like to display the data with LEDs for example.

Dec 15

PIC18F2550 Assembly Tutorial 2

This time we’ll take a closer look at using the flash memory and grabbing data from the program memory. This is used for a wide variety of things such as sine lookup tables. In this example we’ll display some letters (for example your name) on a seven segment display attached to PORTB. I’ve used a Kingbright one if you’d like to do the same, check out the datasheet for the SC56-11GWA.

We start by adding a software flag variable and putting the letter data in the program memory. I’ve put in “FEZ” in the following code bit:

  intFlag equ 0x29
  org 0x820
  DATA 0x71, 0x79, 0x5B

The org directive will tell the compiler to put whatever is coming next in the program memory starting at the address given, 0x820 in this case. The DATA command says which data should be put there. Make sure your other org parameters are correct else you will overwrite other bits of data (the compiler should warn you about this). If you have no idea how 0x71 corresponds to the letter F, I suggest you check out the datasheet of the 7segment display and the following part:

  MOVLW 	0x00 		; Value used to initialize data direction
  MOVWF 	TRISB 		; Set RB as outputs for 7-segment
  ;	RB0 segment 0				0
  ;	RB1 segment 1			5		1    
  ;	...				    	6
  ;	RB6 segment 6			4		2
  ;					      	3   	  7

We configure PORTB as output (do the same for PORTA and C because you should never have floating inputs!). The numbers correspond to the pin of PORTB I connected.

We’d like to be able to see the letters on the display so we need to add some delay, unlike last time where we use software and waste cpu cycles we’re using Timer 0. Time to configure its registers!

  movlw  0x20  ; Disable peripheral - enable TRM0 interrupts
  movwf  INTCON
  MOVLW  0x87   ; 0b10000111;   Presscaler 1:256    
  MOVLW 0x80 ; 0b10000000

A prescaler of 1:256 should be enough, this will make TRM0 overflow about once a second. When it overflows an overflow flag is set and an interrupt is generated, we’ll take a look at that in a minute. The EECON1 is associated with flash & EEPROM memory, take a look at the PIC’s datasheet to see how it’s configurated.

  BTFSS INTCON,TMR0IF  ; Check if TMR0 has overflowed, if not, just return
  BCF INTCON, TMR0IF   ; Mandatory clearing of the TMR0 overflow flag
  BSF  intFlag, 0      ; Set our own software flag

Every time TMR0 overflows it’ll generate an interrupt, but other things can generate one too so we need to check if it was actually the timer who caused it. You HAVE to clear the flag yourself, it isn’t done by the hardware once it is set.

Now we have our registers set and our interrupt routine finished, let’s take a look at the main program:

  CLRF TBLPTRU       ; Set the inital Tabel Pointer values
  MOVLW  0x08
  MOVLW  0x1F

Since we put our data at 0x820 we want the table pointer to point one memory address before the one we want, it’ll become clear why that is with the following part of the code:

  BTFSS intFlag, 0        ; Check if we set the software flag in the interrupt
  GOTO	Main
  BCF  intFlag, 0         ; Here too, we need to clear it if it was set
  INCF  TBLPTRL           ; increment the pointer by one more address
  TBLRD*+                 ; Read the data which TBLPTR is pointing to & increment TBLPTR
  MOVF TABLAT, w          ; Move the readout to W
  MOVLW 0x25              
  CPFSEQ TBLPTRL          ; Have we read out the 3rd letter? Jump back to the first
  GOTO Main
  MOVLW 0x1F
  MOVWF TBLPTRL           ; Set the initial value again
  GOTO Main

So what happens here? We first check to see if we have our software flag high to know TMR0 has overflowed, next we clear it, then we increment the TBLPTR once more so it’s at 0x820. TBLRD*+ will read the data the TBLPTR is pointing at, it’ll also increment the TBLPTRL’s value by one (for some reason it incremented it by one for me, although it probably should increment by 2, not sure why that’s happening). The data is read to TABLAT (table latch), which can then be moved to the working register and moved to PORTB (you can do this in one command by using MOVFF). Once we’ve had all 3 letters, we have to put TBLPTRL back to its initial value so we can start allover.

Now connect your 7-segment display to PORTB and check if it’s working! Also a quick note, I’m using 18F2550 PICs but you can just as easily use a 2553.

If you’re satisfied with the result, continue to tutorial 3.