Welcome! Log In Create A New Profile

Advanced

Do we have counters?

Posted by Tinine 
Do we have counters?
March 30, 2016 09:23PM
I have had the BV508 for a good while now but have yet to play with it.

I am trying to decide between this and a competing product. The *plus* here is the execution speed but the documentation that I have found is not the greatest. I mean, do these chips have counters? If so, what kind of frequency response can we expect. And how are they programmed?

Scheduling:
Can this be considered deterministic? IOW, could I set up a task to execute, without fail, every 1ms?

Cheers!
Re: Do we have counters?
March 31, 2016 10:06AM
hello,
First documentation:
Hardware: http://www.bypic.byvac.com/index.php/BV508
ByPic: http://www.bypic.co.uk/

Counters etc.
The chip is PIC32MX170F256B and so any on chip hardware that is on that chip is available. The rookie firmware gives easy access to the most popular hardware peripherals, GPIO, ADC, timers, I2C etc. but not all as this would make it too big.
The documentation for rookie is here: http://www.bypic.co.uk/index.php/Rookie3

For more advanced peripherals direct register access is available by using @, ?, peek or poke. This enables using anything that is available on the IC. An example is using the on chip PWM which is not in rookie.

Scheduling - Documentation: http://www.bypic.co.uk/index.php/Scheduling. This has been renamed to "task" as it is really multi-tasking rather than scheduling. This is an interesting way to run applications and requires a different approach where all 'top' functions are probably called again and again. It is an alternative to the application being in an endless loop. The program is running but you still get the ok prompt so do not need to stop it to inspect global variables.

A good example is a keypad that may need constant scanning, this can be done via tasking and set a global variable say lastKey or even fill a buffer. Most applications have 3 parts input, process and output. So for example if we have a user interface consisting of an LCD and keypad then we can write this as a separate module and have it run as a task, the task can set and pick up local variables so the processing module only needs to look at say lastKey to see if the user has done anything. The other way round is that the processing module can set a variable that the user interface LCD will pick up and display. The point, is that the user interface can be written and tested independently whilst it is running in the background.

Personally I have been using the task system in preference to all other ways of writing an application and still learning, it does require a different way of thinking and probably not suitable for all applications but so far it has proved to be so much easier.

It is not possible to say how often a task can run as this will depend on the task being run, the minimum time is 1ms but the task may take longer if the function that it is running takes longer. There is an indicator in 'tasksee' called [health] if this is not 0 then the function (or task it does not need to be a function, i.e print "fred") is taking longer than the time interval between tasks.

The documentation at ByPic is massive and fragmented. The ideal would be a book(let) (or series of videos) to introduce the basics -- waiting for volunteers.

Finally:
The main advantage of using ByPic over a compiled language such as C is the interactivity it offers and the shear speed of building applications - a bit like WYSIWYG for microcontrolles.
Re: Do we have counters?
March 31, 2016 03:41PM
Hi Jim,

Thank you for the rapid response and also for a very interesting and exciting product(s).

Oops, it seems that I have the BV509, not the 508 so presumably, the code execution will be ~double that of the 508?

Assuming that my code execution happens within the 1ms ISR, can these tasks be regarded as "hard real-time" or can they be disrupted by events happening elsewhere within the code?



Edited 1 time(s). Last edit at 03/31/2016 07:53PM by Tinine.
Re: Do we have counters?
April 01, 2016 07:57AM
hello,
the task scheduler is NOT an interrupt but can be interrupted if an interrupt is set. Nothing happens within the code to these tasks unless the user sets an interrupt.

The task is run whilst waiting for the user input which is by default all of the time. The only exception to this is the interrupt that will occur without the user setting it is the RX input.

Just a note; the tasker is not intended for exact timing. If that is required then one of the timers should be used. ByPic is fast compared to other interpreted language as as it compiles functions to machine addresses however if your applications requires fast and regular responses, lets say check something every 200uS then ByPic by itself will not do it. There are lots of ways round it, for example using a hardware peripheral ByPic can send SPI out at 10MHz (100ns) and capture same, or a C plug in can be used. But if most of the code actually requires this kind of response then it is better to code in C
Sorry, you do not have permission to post/reply in this forum.