Page 1 of 1

Updating output pins at speed

Posted: 30 June 2019, 14:50 PM
by FFMan
Pursuing my ongoing obsession with clock projects i decided to try and recreate an oscilloscope clock that was executed so well here

http://www.dutchtronix.com/ScopeClockH3-1-Enhanced.htm

I was intending to use a 328n but I note that there is not an entire output port of 8 pins available (to drive an external DAC AD7302) as for speed i was going to address the register directly such as:-

register.portb=255

but as an entire port is not available I've ended up with some code as below that users a pin map in an array where the pins could be any values.

With this code I can achieve approx 6,500 adc updates per second. If i remove the loop, i can achieve approx 30,000 but of course it doesn't work.

I could move to a zx40 as a solution or even a 128a1 I have which has the benefit of higher clock speed also, but i wondered if there was a simpler solution ?

Code: Select all

'Sub to write the binary data to the correct pins
Sub ADC7302PutData(byVal byData as byte)

	dim byLoop as Byte
	
	for byLoop=0 to 7
	
		Call PutPin(by7302Data(byLoop+1),GetBit(byData,byLoop))
		'debug.print byLoop;" pin=";by7302Data(byLoop+1);" bit=";GetBit(byData,byLoop)
		
	next
	
end sub

Re: Updating output pins at speed

Posted: 01 July 2019, 10:35 AM
by dkinzer
FFMan wrote:[...]i wondered if there was a simpler solution ?
An alternative that would likely be faster would be to have two parallel arrays - one with the PORTx address and one with a bit mask (exactly one bit set). Then, for each bit you can set or clear the bit in the PORTx as appropriate. Alternatively, for each bit you could clear the bit and then if it should be set, set it.

Posted: 03 July 2019, 1:42 AM
by FFMan
i moved to a zx40 so could address entire io port in 1 command and speed is better but borderline for what i want to achieve.

i either need a tube with longer persistence or faster processor.

I note the original kits where done on PICS, not sure what speed what they ran at but is the code lower level ?

What would be the quickest zbasic platform at the moment ?

Posted: 03 July 2019, 7:08 AM
by dkinzer
FFMan wrote:i moved to a zx40[...] and speed is better but borderline for what i want to achieve.
Is it a ZX-40 or a ZX-40n? The latter would be significantly faster.
FFMan wrote:What would be the quickest zbasic platform at the moment ?
All of the xmega devices run at 29.4MHz compared to 14.7MHz for the native mode ATmega-based devices. The number of cycles for a given code sequence would be similar for mega and xmega so you would get roughly twice the throughput with an xmega.

Posted: 03 July 2019, 7:37 AM
by FFMan
it's a zx40n - i don't use the vm devices any more.

twice the speed is better - i'll see how it goes

Re: Updating output pins at speed

Posted: 01 August 2019, 23:23 PM
by kranenborg
FFMan wrote:Pursuing my ongoing obsession with clock projects ...

I was intending to use a 328n but I note that there is not an entire output port of 8 pins available (to drive an external DAC AD7302) as for speed i was going to address the register directly such as:-

register.portb=255

but as an entire port is not available ...
You actually can make a full 8-bit output port available for use with those operations on the ZX-328 and the likes, see: www.zbasic.net/forum/viewtopic.php?t=14 ... pc_t=59724


Regards,
Jurjen

Posted: 11 August 2019, 12:51 PM
by rich
It would be faster if you did not use putPin.

Write directly to the registers with register.<name> for each slice of output register.

This would mean the pins would need be fixed but is that a problem.

Richard