Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 21:57 27 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : MMBasic 4.4 Beta 4

     Page 2 of 3    
Author Message
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 10:30pm 11 Jun 2013
Copy link to clipboard 
Print this post

  cwilt said   Its just me then?

Ah, sorry - I should have answered that.

The effect is produced by a bug in the PIC32's SPI and I have to hand tune the code with each release to eliminate it. I did a quick job with this beta but obviously not good enough.

When the final release comes out I will do some more extensive checking/tuning and it should be fixed then.

GeoffEdited by Geoffg 2013-06-13
Geoff Graham - http://geoffg.net
 
ajkw
Senior Member

Joined: 29/06/2011
Location: Australia
Posts: 290
Posted: 10:37pm 11 Jun 2013
Copy link to clipboard 
Print this post

Geoff,
4.4Bv2 is working fine in regards the watchdog. An observation is that WATCHDOG RESET will enable the watchdog even it was previously disabled.

  Quote  Its just me then?
I have to say I looked curiously at the monitor last night thinking there was a ever so slight green hue to the white pixels but ..., dunno. Seems alright tonight. As I write I see Geoff has just posted.

Anthony.

 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 10:41pm 11 Jun 2013
Copy link to clipboard 
Print this post

  Geoffg said  
  TZAdvantage said  
Good idea but it will not work. To quote from the manual:
  Quote  To ensure the 128-bit data integrity of each Configuration Word, a comparison is continuously made between each Configuration bit and its stored complement. If a mismatch is detected, a Configuration Mismatch Reset is generated causing a device Reset.


Do you know how to turn off the Configuration Mismatch Reset?

I also tried writing to WDTCONbits.SWDTPS but that is ignored.

Geoff

The next part in the documentation is:
[code]
32.3.2 Device Code Protection
The PIC32MX features a single device code protection bit CP that when programmed = 0,
protects Boot Flash and Program Flash from being read or modified by an external
programming device. When code protection is enabled, only the device ID word
locations are available to be read by an external programmer.

Boot Flash and Program Flash memory are not protected from self-programming
during program execution when code protection is enabled.

Section 32.3.3 provides more information.
[/code]
The bold part confuses things as it says that it can be written. But that is also depended on Program Write Protection bits.
I agree that in practice there are to many variants of boot loaders with different configurations to be able to make it work.
I guess the same problems arose for using the internal RTC?
I understand the design, for embedded situations you configure it and leave it at that. General purpose was not really the intention. :)
Edited by TZAdvantage 2013-06-13
Microblocks. Build with logic.
 
ajkw
Senior Member

Joined: 29/06/2011
Location: Australia
Posts: 290
Posted: 11:28pm 11 Jun 2013
Copy link to clipboard 
Print this post

Perhaps a little more food for thought.

IF you exit a running program, with CTRL-C, that has enabled the WD you have no more than 4 seconds at the command prompt to save your work or type in without error in a panic WATCHDOG DISABLE, tough in < 4 Seconds.

2 ideas,

with CTRL-C disable the WD, but, does this potentially diminish the WD function and potential reliability??

or

Use an OPTION Fnn . However this has a problem, WATCHDOG DISABLE is more than 12 characters.

Anthony.
Edited by ajkw 2013-06-13
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 11:47pm 11 Jun 2013
Copy link to clipboard 
Print this post

You should only have the watchdog running in the final unattended production version. Although I concede, it would be nice to have CTRL-C available even then. In the final version of 4.4 you will be able to specify the timeout and that could be used to give you enough time to disable it.

Geoff Edited by Geoffg 2013-06-13
Geoff Graham - http://geoffg.net
 
cwilt
Senior Member

Joined: 20/03/2012
Location: United States
Posts: 147
Posted: 04:41am 12 Jun 2013
Copy link to clipboard 
Print this post

  Geoffg said  
  cwilt said   Its just me then?

Ah, sorry - I should have answered that.

The effect is produced by a bug in the PIC32's SPI and I have to hand tune the code with each release to eliminate it. I did a quick job with this beta but obviously not good enough.

When the final release comes out I will do some more extensive checking/tuning and it should be fixed then.

Geoff


No problem. I just wanted to make sure it wasn't my setup since I just put my UBW32 Colour back together. The addition of loadable and unloadable modules brought me back.
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 05:00am 12 Jun 2013
Copy link to clipboard 
Print this post

  Geoffg said  
This is the end of my todo list for V4.4. I would like to make V4.4 the final release for some time (other than critical bug fixes) so, if you have an important feature that you think should be in MMBasic, now is the time to speak up. Remember that any potential addition must be useful to a lot of people, fit within the language and not doable in BASIC. Also I cannot guarantee that all (or any) suggestions will make it in.
Hi Geoff,
I have two prospective commands that I'd like (getting greedy) and I think they'd be useful to a fair audience.

First:
Is it possible to have two TIMER interrupts i.e. TIMER1 and TIMER2.

Second:
Could there be a variation of the PULSE command that's good for multi-servo control - for models and robots. It would need to be able to pulse up to say six or eight outputs (some masochists use up to twelve) which could be consecutive like the PORT command, but each with different and changing pulse widths (e.g. from reading separate analogue-in pins - which the main program could do). The pulse widths would each need a 'resolution' similar to the current PULSE command, i.e. minimum increments of about 0.02 millisecs, but only needing a range starting at about 0.4 mS and extending up to about 3.0 mS. The pulses need to be maintained (run in the background?) at a frequency around 50 Hz but the accuracy of that only needs to be probably +/- 10%. We can use the current single TIMER interrupt to get the 50 Hz but it's then 'used up' and wasted somewhat because only a 'rough' 50 Hz is required and that frequency will always be the same for servo control.

Guess this latter one's a pretty big 'ask', and maybe it's better done with a special chip but then, maybe it's possible.

Greg
 
kiiid

Guru

Joined: 11/05/2013
Location: United Kingdom
Posts: 671
Posted: 01:02pm 12 Jun 2013
Copy link to clipboard 
Print this post

I am not sure how much my modest opinion can have effect on Geoff's decisions, but my long time spent on computers and my guts tell me to firmly believe that WATCHDOG command is a VERY BAD idea.
Sure, watchdog as such is great to have in MMBasic, but the very concept of the watchdog operation is far away from the Basic. There are (at least) two layers of software between the user program and the bare hardware and a command to directly control the watchdog creates a direct tunnel between the Basic program and the hardware. A tunnel, which could easily lead to unstable operation of the whole system.
The watchdog operation should be an integral part of the MMBasic for the same is acting as an OS here as well. It must not be available to the end user under any conditions.
This is what I think.

http://rittle.org

--------------
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1109
Posted: 01:37pm 12 Jun 2013
Copy link to clipboard 
Print this post

I have a couple of MMBasic requests.

1) Sound status/control

The Tone command could, I think, benefit with some more control. The first change would be the ability to return current tone status, active or finished. At the moment, to play a tune, for example, you would start a note (Tone 440,0,500 for example) and then pause (Pause 500) until the tone is finished. Would it be possible to have something like the following?

Do While Tone 440,0,500
<maybe more statements>
Loop

The next enhancement to Tone command would be individual control over left and right channels. Perhaps putting a negative value for the left or right frequency could mean don't change whatever that channel is already doing (or not doing.)

(Something I haven't checked is what happens if you 'Tone Stop' with no active tone. If it generates an error, I would hope there is a way to ignore that error.)

2) Sprite improvements

a) A way to turn off sprites that might already be off. Or a way to ignore the resulting error when trying to turn off a sprite that is already off. Why would a program not know if a sprite is on? Interrupts might have changed something that the main routine is unaware of without excess data keeping.

Alternately, a way of checking if a sprite is on or off.

b) A means of displaying a given sprite more than once. Nick presented what seems to me like a nice solution with his SPRITE COPY command idea.

Pete.

Visit Vegipete's *Mite Library for cool programs.
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1101
Posted: 01:48pm 12 Jun 2013
Copy link to clipboard 
Print this post

Geoff,

Would it be possible to have the keyboard and the usb inputs interrupt driven? That is, when a key is pressed, the program would divert to an interrupt routine. This would allow asynchronous handling of input rather than just waiting in loop for user input.

It could be an addition to the KEYPRESS command, to include an optional argument that is the label of the interrupt handler.

For your consideration and/or comment,

Regards, Doug.

... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
Bill.b

Senior Member

Joined: 25/06/2011
Location: Australia
Posts: 226
Posted: 03:21pm 12 Jun 2013
Copy link to clipboard 
Print this post

From Greg

  Quote  Could there be a variation of the PULSE command that's good for multi-servo control - for models and robots. It would need to be able to pulse up to say six or eight outputs (some masochists use up to twelve) which could be consecutive like the PORT command, but each with different and changing pulse widths (e.g. from reading separate analogue-in pins - which the main program could do). The pulse widths would each need a 'resolution' similar to the current PULSE command, i.e. minimum increments of about 0.02 millisecs, but only needing a range starting at about 0.4 mS and extending up to about 3.0 mS. The pulses need to be maintained (run in the background?) at a frequency around 50 Hz but the accuracy of that only needs to be probably +/- 10%. We can use the current single TIMER interrupt to get the 50 Hz but it's then 'used up' and wasted somewhat because only a 'rough' 50 Hz is required and that frequency will always be the same for servo control.



this will control upto 21 servos using I2C and maintain the correct timming
on all servos.

Serv control

Bill
In the interests of the environment, this post has been constructed entirely from recycled electrons.
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 03:02am 13 Jun 2013
Copy link to clipboard 
Print this post

Hi Bill,
Yes I might have to go to something like that eventually - currently it's overkill though for what I was thinking.
Greg
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1425
Posted: 04:38am 13 Jun 2013
Copy link to clipboard 
Print this post

  panky said   Geoff,

Would it be possible to have the keyboard and the usb inputs interrupt driven? That is, when a key is pressed, the program would divert to an interrupt routine. This would allow asynchronous handling of input rather than just waiting in loop for user input.

It could be an addition to the KEYPRESS command, to include an optional argument that is the label of the interrupt handler.

For your consideration and/or comment,

Regards, Doug.


Something like ON KEY.
Micromites and Maximites! - Beginning Maximite
 
StoveMan
Regular Member

Joined: 29/03/2013
Location: United States
Posts: 51
Posted: 05:16am 13 Jun 2013
Copy link to clipboard 
Print this post

Geoff Wrote:
  Quote  This is the end of my todo list for V4.4. I would like to make V4.4 the final release for some time (other than critical bug fixes) so, if you have an important feature that you think should be in MMBasic, now is the time to speak up.

Thanks for your work Geoff.
Can the PWM outputs default to "off"? When using the hardware PWM for analog out (usually to control a servo valve or motor via an RC filter), the usual safe state is 0 volts. Even with the cool new watchdog watching, the affected hardware will swing wildly to 100% until RESET.BAS can get it under control, right?

I am using an active low pin as an enable right now. If you feel that adjusting the language is the hard way round I will understand. Could be no one else is using analog output to move something large. But as long as we are trying to make a robust controller out of this...?
Regards, Frank
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 03:25pm 14 Jun 2013
Copy link to clipboard 
Print this post

Thanks for the great suggestions. This is the list (as I see it) and my notes. Any more suggestions or comments anyone?

> Two TIMER interrupts i.e. TIMER1 and TIMER2
Do you mean something like SETTICK1 and SETTICK2 (this is how you setup a timed interrupt). This is doable, but you can get the same effect by counting inside the interrupt and calling another sub when a count has been reached. Or have I misunderstood the requirement?

> Multiple PULSE outputs for driving multiple servo's.
This would be very hard if not impossible. The PIC32 is a busy chip with many timers and interrupts and something like this would require a very high speed interrupt which would play havoc with the video, keyboard, etc.

> Return current tone status, active or finished.
I will have a look at this one, but it does seem simple enough to use the timer:
TONE 440,0,500
TIMER = 0
DO WHILE TIMER < 500
<maybe more statements>
LOOP

> Individual control over left and right TONE channels.
I guess that you mean turning off the tone on one channel while the other continues running. I suppose that it could be done but I cannot see that a lot of people would need it.

> A way to turn off sprites that might already be off.
The suggestion to not throw an error is sensible and it can also apply to turning off TONE, PWM and similar functions. Easily done.

> A means of displaying a given sprite more than once.
OK, I will re look at Nicks suggestion. I must admidt that I did not properly understand how it would help dispite Nick's patient explanation.

> Keyboard and the usb inputs interrupt driven (something like ON KEY).
Interesting one. I will do some research to see how it could be implemented - and I will put it in if I can.

> PWM outputs default to "off"
Yes, definately. And it should be straight forward to implement.

Also, I have to go through what kiid has done with his version of MMBasic for his version of the mono Maximite as there is some good work there.

Thanks for the input,
Geoff
Geoff Graham - http://geoffg.net
 
CircuitGizmos

Guru

Joined: 08/09/2011
Location: United States
Posts: 1425
Posted: 05:07pm 14 Jun 2013
Copy link to clipboard 
Print this post

Geoff: I have some various BASIC books that cover different flavors of BASIC. Let me know if you want me to look through them for reference to some commands.
Micromites and Maximites! - Beginning Maximite
 
paceman
Guru

Joined: 07/10/2011
Location: Australia
Posts: 1329
Posted: 06:50pm 14 Jun 2013
Copy link to clipboard 
Print this post

  Geoffg said   > Two TIMER interrupts i.e. TIMER1 and TIMER2
Do you mean something like SETTICK1 and SETTICK2 (this is how you setup a timed interrupt). This is doable, but you can get the same effect by counting inside the interrupt and calling another sub when a count has been reached. Or have I misunderstood the requirement?

Yes, sorry Geoff I explained that poorly, the SETTICK1 and 2 is what I was thinking. I see your point that doing it inside the interrupt is a possibility but I was trying to keep the interrupt routines pretty minimal so they'd get back to the main program quickly. Having another one inside the interrupt routine calling another subroutine seems like it could get pretty complicated to me - I think I'd probably lose track of where I was trying to debug things, but then I'm a pretty ordinary programmer!
  Geoffg said  
> Multiple PULSE outputs for driving multiple servo's.
This would be very hard if not impossible. The PIC32 is a busy chip with many timers and interrupts and something like this would require a very high speed interrupt which would play havoc with the video, keyboard, etc.
Geoff

I thought that would probably be the case but thanks for thinking about it anyway. I think this is one that'll have to be sent off to another chip or processor or board.
Thanks again,
Greg
 
Juri74

Senior Member

Joined: 06/02/2012
Location: Italy
Posts: 162
Posted: 10:25pm 14 Jun 2013
Copy link to clipboard 
Print this post

  Geoffg said   Thanks for the great suggestions. This is the list (as I see it) and my notes. Any more suggestions or comments anyone?

1> Two TIMER interrupts i.e. TIMER1 and TIMER2
Do you mean something like SETTICK1 and SETTICK2 (this is how you setup a timed interrupt). This is doable, but you can get the same effect by counting inside the interrupt and calling another sub when a count has been reached. Or have I misunderstood the requirement?

2> Individual control over left and right TONE channels.
I guess that you mean turning off the tone on one channel while the other continues running. I suppose that it could be done but I cannot see that a lot of people would need it.

3> A way to turn off sprites that might already be off.
The suggestion to not throw an error is sensible and it can also apply to turning off TONE, PWM and similar functions. Easily done.

4> A means of displaying a given sprite more than once.
OK, I will re look at Nicks suggestion. I must admidt that I did not properly understand how it would help dispite Nick's patient explanation.

5> Keyboard and the usb inputs interrupt driven (something like ON KEY).
Interesting one. I will do some research to see how it could be implemented - and I will put it in if I can.

Geoff


these are request from users i think could be interesting/useful in a future update of maximite

1) i will do multiple interrupt using the technique of counting inside an interrupt... however, having two distinct interrupts would be very useful as i could disable the 2nd interrupt with a command and not using "if" inside the first irq routine, an idea for mantaining a backward compatibility to the ol command is not to use SETTICK1 & SETTICK2 commands but one command "SETTICK PERIOD, TARGET [,IRQNUMBER]" so "settick 100,myroutine,2" will activate the second irq to myroutine every 100millis... if no number is given to IRQNUMBER option then is assumed only irq1 is activated "settick 100,check" will activate standard irq (1) to check routine every 100 millis..

2) i think that having indipendent controls over channels would be very,very useful! this could be more useful if could be possible having left channel doing sine wave while right channel is doing PWM (and viceversa)!
in a game this will result having a channel play a music, while the other channel play sfx

3) i agree this, better have no errors if i turn off a sprite that is already off..

4) In games: indispensable!

5) very interesting, could be interrupted? example i put a command at start of program like "ON KEY myroutine" so when i press a key on keyboard program halt an go to myroutine, exiting with a IRETURN command

Juri
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 11:21pm 14 Jun 2013
Copy link to clipboard 
Print this post

  StoveMan said  Can the PWM outputs default to "off"? When using the hardware PWM for analog out (usually to control a servo valve or motor via an RC filter), the usual safe state is 0 volts. Even with the cool new watchdog watching, the affected hardware will swing wildly to 100% until RESET.BAS can get it under control, right?

OK, I have investigated this one and the result is that when you issue a PWM STOP command the outputs go to high impedance (ie, they are neither off or on). This is also the state that they are in when the PIC32 is first powered on. This is standard microcontroller behaviour.

As far as I can see you will have to live with this because, when the PIC32 is reset, all its I/O pins are set to high impedance and there is a finite time before MMBasic starts running. So, it is impossible for me to guarantee that the outputs will always be pulled to logic low.

If you want to make the outputs default to low then all you need is a resistor to ground so that they are pulled low when in the high impedance state. Similarly, if you wanted the PWM to be "full on" you could pull the pins up to 3.3V.

BTW I discovered a bug in the PWM code which meant that the PWM duty cycle only had a resolution of 1%. It should be 0.1% and that will be fixed in the next beta.

Geoff
Geoff Graham - http://geoffg.net
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 11:32pm 14 Jun 2013
Copy link to clipboard 
Print this post

  Juri74 said  1) i will do multiple interrupt using the technique of counting inside an interrupt... however, having two distinct interrupts would be very useful as i could disable the 2nd interrupt with a command and not using "if" inside the first irq routine, an idea for mantaining a backward compatibility to the ol command is not to use SETTICK1 & SETTICK2 commands but one command "SETTICK PERIOD, TARGET [,IRQNUMBER]" so "settick 100,myroutine,2" will activate the second irq to myroutine every 100millis... if no number is given to IRQNUMBER option then is assumed only irq1 is activated "settick 100,check" will activate standard irq (1) to check routine every 100 millis..

2) i think that having indipendent controls over channels would be very,very useful! this could be more useful if could be possible having left channel doing sine wave while right channel is doing PWM (and viceversa)!
in a game this will result having a channel play a music, while the other channel play sfx

Thanks. The first is a neat way of implementing the functionality. I will have a look at it but I am still wary of loading down the processor with too many counting/timing functions.

I can see that the second suggestion would provide tremendous flexibility but at the same time it would be way too complex and the syntax of the commands would be a nightmare.

GeoffEdited by Geoffg 2013-06-16
Geoff Graham - http://geoffg.net
 
     Page 2 of 3    
Print this page
© JAQ Software 2024