ts-7000
[Top] [All Lists]

Re: [ts-7000] Re: PWM (Uploaded file ts7500_pwm)

To:
Subject: Re: [ts-7000] Re: PWM (Uploaded file ts7500_pwm)
From: Jonatan Olofsson <>
Date: Tue, 7 Dec 2010 18:16:43 +0100


Thank you for you input.


I uploaded the generador_pwm.v-file that i had locally. However, note that i had translated the variables (and module name) for my own understanding.. This unfortunately breaks compability with the original implementation. 

I'll see if i can get time to try to get this working some time soon. My actual goal is to modify the code to generate servo signals, and will of course conribute any successful attempt back to the list.

Best regards,
Jonatan

On Tue, Dec 7, 2010 at 05:23, akikem <> wrote:
 

Hi Jonatan,

Sorry, I have been busy, but I have just updated the ts7500_pwm file. I replaced it with the code I am using for my project. I did it because I know the space in the group is limited, so I don't feel okey, like uploading a lot of files doing almost the same. But if moderators don't mind, we could upload both of them. I just uploaded the one with more work (I created more verilog files in this one), so it can be used as an example.

This new code delivers 6 pwm, from pin 31 to pin 36, one by one, and each one lasting from 1.5 to 3 seconds as far as I remember. Also, every time the 6 pwm are activated, pin 40 turns on for a second.

The registers I am using are 0X6A for setting up the PWM, and 0X68 for info/debugging. 0X6A register works as following:

15-11 bit --> Frequency: Actually it works only for 73khz aprox, to 76khz. That's because it's the one I need for a TULA actuator to move.
10-4 bit --> Duty cicle. I think it works from 99 to 1, but I haven't tested enough.
3-1 bit --> Enable time. From 1.5 to 3.25 seconds on .25 steps. That's the time the PWM will last in each pin.
0 --> Start. You need to activate this bit to produce a PWM. Because of the timer you don't need to change it to 0, so it will stop. However, if you want next pin activate PWM, you have to set it to 0, and then 1 again, to activate it. In other words:
Start 0 --> Nothing happen.
Start 1 --> PWM1 activates. After less than 3.25 seconds, deactivates.
Start 0 --> Nothing happen.
Start 1 --> PWM2 activates. After less than 3.25 seconds, deactivates.
So on...

The full command could be:

ts7500ctl --address=0x6A --poke32=0x32f <-- This will enable a 50% duty. I will enable, for example PWM1 (if it's the first time I use the command, or after a reset) for the maximum time.

ts7500ctl --address=0x6A --poke32=0x32e <-- This will pull down start to 0. Actually you can use --poke32=0x000 and the result is the same.

ts7500ctl --address=0x6A --poke32=0x4bf <-- This will enable a 75% duty. If we follow the example PWM2 will be enabled for the max time too. (Like 3.25 seconds).

ts7500ctl --address=0x6A --poke32=0x0000 <-- This will pull down start to 0 again, so you can use PWM3 next time.

If you actually READ (peek16) the register 0X6A, you would see the values you have just inserted. But if you read register 0x68 you would find information about which PWM have just activate, and if it is still on, and if you have activated reset.

In syscon file, search for this lines:

Code:
// 5'ha: dio[36:21] <= wb_dat_i[15:0] & dio_mask[36:21];

5'ha: {frecuencia,duty,tiempo_espera,inicio} <= wb_dat_i;
---

The commented line is actually the one I removed which uses space in 0X6A as DIO. But in the other, as you can see, I am writing the data in the wishbone bus, to my variables "frecuencia" (frequency), "duty", "tiempo_espera" (delay time) and "inicio" (start).

If you look a little bit before, you can find:

Code:
if (wb_cyc_i && wb_stb_i && wb_we_i) case (wb_adr_i[4:0])
---
I haven't fully tried to understand wishbone protocol, but the case here, is looking for the address of the register. This part of the code is Linux-->FPGA part. That is, when you write something from Linux to the FPGA register part.

Lines down, you can find

Code:
always @(*) begin

wb_ack = wb_cyc_i && wb_stb_i;

wb_dat = 16'hxxxx;

feed_en = 1'b0;

case (wb_adr_i[4:0])
...
...
---
This is when you do Linux<--FPGA. That's when you read some value in the FPGA register on Linux.

I haven't study enough all the lines, and I didn't wanted to override some useful function on the board, that's why I tried to create my own code apart from TS code. I am sure you can use most of the pins to do PWM, but you will loose SPI, and DIO and the other functions there.
However, I think you need to be careful (I don't know it for sure... but I don't want to take any risks) when you assign the pads, because they are already soldered in the board... so if you override some clock pad, or if there is something associated with Flash, or the microSD Card, the program would allow you to, but then you will have troubles with the board itself.

I hope this answer the part of the syscon register (try to find the lines I just wrote).

About multiple PWM, in this project, look for the top_pwm file, that's under PWM/top_pwm. As you can see, I am declaring 6 entities of PWM, and I am assigning each output to the bus o_pwm.
Then if you go to syscon file, you can see I am assigning that bus, to another one with the same name (o_pwm). And at last, look at ts7500_top.v, and you can see I also assign that bus to pwm_pad pins.

Now, compiling. You need to download lattice ispLever. You can find it in the Lattice Semiconductor page. It will only runs under windows, but you can use a virtualbox. I tried it under wine, but it doesn't work always and I didn't spend time find out why.

I would recommend you to first try to compile the whole file. Then, try to do some modifications on syscon, or directly on ts7500_top, and look if you understand how to modify it.
If you create new pads, don't forget to assign them to the correct pins. Use the Design Planner tool in ispLever. It's a little bit confusing, but that's the tool you need.
After you have made the modifications, and assigned the pads, create the JEDEC file, and then, look for the TS tutorial where they explain how to upload a jedec file into the ts7500.

Finally... I will be really busy this week and the next one. But if I can help somebody to create a howto, or some kind of tutorial, I will be glad to help.
I think my verilog programing skills are low, but if they are useful, you have my help.

Aaand.. I have a favor to ask. While I was writing this, I though I wouldn't have erased the old pwm file, because maybe it was more useful than this one. Could you upload it again? I hope moderators don't mind.

Thanks!

Enrique




--- In ts-7000%40yahoogroups.com, Jonatan Olofsson <> wrote:
>
> Hi,
>
> I'd like to thank you for doing work on this matter. I too have interest in
> using pwm from the TS-7500. I havn't done very much fpga
> before (and only VHDL, no Verilog), but I've read the generador_pwm and it
> seems quite clear to me (after I understood the variable names =) ), and i
> think i understand most of the important parts in syscon.v
>
> Now, i have a few questions that i do not quite understand yet
> 1) How does the connection to the linux-available registers work? I could
> not find any of it in the code..
> 2) How do you interface multiple PWM's from the registers? I think there was
> a notice on it in the thread, but i did not quite understand fully..
>
> Also, and i must beg your pardon for asking such a seemingly trivial
> question, how do you compile it? I suppose I replace the syscon.v file in
> the opencore's source, add the generador_pwm file and then..... something
> more =). Then even more something to get write it to the fpga.
>
> It would be really nice to see an implementation and documentation on this.
> I would be more than willing to compile such a how-to if I could get the
> help to get it working. I've seen several sources online watching this
> thread with anticipation, so I know it would be appreciated.
>
> Best regards
> Jonatan Olofsson
>
> On Sat, Nov 27, 2010 at 17:49, Ferrug <> wrote:
>
> >
> >
> > Hi Enrique,
> >
> > Thank you again for your help..
> > I had sucess in do my two PWM work fine with double of resolution. Of
> > course, with your big help.
> > Now, my problems are in the SPI communication. hehe
> > I will dedicate my efforts on it.
> > If you need anything in my power, be sure to ask. I'll be happy to help.
> >
> > Best Regards
> > Fábio Luiz
> >
> >
> > 2010/11/24 David Preza H <>

> >
> >
> >>
> >> Fabio,
> >> Thanks for the code. Sorry I haven't updated my advances. I think I have
> >> my 6 pwm code working properly now.
> >> It use address 0X6A and 0X68. The first one to configure the PWM, the
> >> second one to inform about the configuration.
> >> However, the way it works (because I need it that way), is sequentially,
> >> first the PWM1 is activated, then the PWM2, and so on. After PWM6, a bit is
> >> enable for a few moments, and it returns to PWM1.
> >> You can control frequency, from 73khz, to 76khz approx. You can vary duty
> >> cicle from 0 to 100 ( I have tested 25, 50 and 75), and it will keep PWM on
> >> for 1 to 3 seconds.
> >> I will upload all this code, maybe there's something useful.
> >>
> >> About your code, you're working with a 50Khz frequency now, but I don't
> >> get exactly why your duty cicle isn't changing. Does it works with a 1000
> >> resolution?
> >>
> >> Regards,
> >> Enrique
> >>
> >>
> >
> >
> > --
> > "Dê-me uma alavanca e um bom ponto de apoio que moverei o mundo."
> > Archimedes
> >
> >
> >
>




__._,_.___


Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: =Email Delivery: Digest | m("yahoogroups.com?subject","ts-7000-fullfeatured");=Change Delivery Format: Fully Featured">Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | =Unsubscribe

__,_._,___
<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU