Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - evanh

Pages: 1 2 [3] 4
31
Technical support / Re:Square root
« on: December 16, 2005, 03:29:52 AM »
And if you want rounding to nearest, instead of rounding down, it changes in detail but not really all that much:

square=12345678 ' The number we want to find the square-root of.
sqroot=0 ' The resultant square-root.
index = &8000 ' The bit mask indexing.
check = 0 ' The lookahead sqroot - Added for faster execution.

sqrt_loop:
  check = sqroot + index
  index = index >> 1
  if (check * check - check) < square then sqroot = check
  if index<>0 then sqrt_loop


Evan

32
Technical support / Re:Square root
« on: December 14, 2005, 07:27:39 PM »
I haven't tried to compare but the method I've used in the past uses a multiply instead of divide per iteration.  It's a simple binary search - If you want a 16 bit result from a 32 bit source then it always takes 15 iterations and is not an estimate so it's as accurate as 16 bits can be.  Combined with the multiply, which is often a lot faster than a divide, then the binary search method might be a better solution.


The search loop goes something like:

square=12345678 ' The number we want to find the square-root of.
sqroot=0 ' The resultant square-root.
index = &8000 ' The bit mask indexing.

sqrt_loop:
   sqroot = sqroot + index
   if sqroot * sqroot > square then sqroot = sqroot - index
   index = index >> 1
   if index<>0 then sqrt_loop



Evan

33
Technical support / Re:How compiled is the code?
« on: December 10, 2005, 11:13:18 AM »
Just had an online look at some System-On-Chip parts but they are not too suited to industrial apps ... My favorite choice so far is a high-end microcontroller:  http://focus.ti.com/docs/prod/folders/print/tms320f2811.html

This beast has a 16 FIFO SPI and also a configurable serial controller, both of which could do a great job of pacing the I/O transfers with little attention from the CPU.  Or should I say DSP?   ;)

The F2812 has an external bus if more memory is wanted but that will be slower access speed and even then will still have quite steep demands on the external memory me thinks.  There is also the F2808 for a smaller variant and has more serial ports including a second CAN port.

And another neat thing is that all the counter inputs have direction control too so even the ones that don't have quadrature decoders built-in can still do the job with a small amount of external logic, as little as two flipflops per counter, that can easily fit in a single combined PLD.  That's up to four encoder inputs with greater than 1 MHz rating and no processing demand on the CPU.

One down side is the I/O pins are 3.3 volt so it'd be happier if all external wiring was done at 3.3 volts.  This should be doable though, opto-couplers and transistor arrays are happy at that voltage and PLDs are already there.


Evan

34
Technical support / Re:TL53.jar almost works native in Linux
« on: November 16, 2005, 12:40:44 AM »
It really works!  :)

The serial driver allows me to both program and monitor the PLC so we have a winner in terms of function.  That's the good news.

The bad news is that the fonts are still having serious problems.  I'll work on how to config these with the new TL60.jar, hopefully it'll make a dif ...


Cheers,
Evan

35
Technical support / Re:How compiled is the code?
« on: November 15, 2005, 01:55:30 PM »
Nah, offence wasn't taken at all.  I rather enjoyed the exchange.

It's not often the front tech support is so informative/knowledgeable about their product so I took the chance that I might be able to help with future design improvements which you have just indicated are indeed planned.

As for the filtering, it looks like it won't make a big difference to the T100s but, I ment that the I/O scan itself should utilise multiple scan-cycles of the whole PLC as it's filtering timebase instead of the existing inline delay.  So, the ladder logic still sees nice clean switching and gets a small speed boost to boot.

I do realise any such ideas require reburning the firmware so I'm not expecting enhancements for existing PLCs.

The obvious, but hardware demanding, solution to the serialised digital I/O taking time to arrive is to have some reconfigurable logic (hardware) in the uC that cycles the I/O itself and presents a buffer or full map of the I/O space mapped into CPU space so it can be accessed as full speed local RAM.  Not unlike a UART with a decent FIFO.


Evan

36
Technical support / Re:How compiled is the code?
« on: November 14, 2005, 11:39:31 PM »
Hmm ... puffed chest ... cards on the table then.

That was a very quick reply, maybe a bit too hastie, I didn't say not to filter.

Ok.  I understand the compactness of tokenising but compiling isn't going to be much different in size once you account for the built-in libs of the interpreter.  I suspect this really might be an issue of self-programming of program space in the uC or reliability of compiling or recovering from corrupted PLC.  Yep, most(all?) other PLCs also use tokenised code, so I'm not going to say compiling is the best answer.

I do have doubts about your argument that it is fast enough for a PLC, speed is always a concern.   Modern "name-brand" PLCs are getting very fast compared to earlier models, it's a selling point.  Of couse, I admit, with faster execution comes demand for larger program and data space.


evanh's ego.

37
Technical support / Re:How compiled is the code?
« on: November 14, 2005, 08:50:21 PM »
Cool reply!

But, but, but, filtering can be done over many cycles ... I mean, eek!, I'd never put inline delays in my own dedicated programs so I certainly don't want it forced by the OS.

That said, I think the situation is actually worse still.  I done a little experimenting by removing the bigger lines of code, namely the ADC reads, the sixteen adds, and the multiply-divide.  This got me from the 160 Hz (6.3 ms) up to around 380 Hz (2.7 ms) which is approaching the 2 ms I/O scan limit.  Makes sense and all but not a good figgure for so few commands.

Btw:  The sixteen adds took the lions share of around 2.2 ms.  :(


Evan

38
Technical support / Re:ADC normalisation
« on: November 14, 2005, 06:51:44 PM »
Nope, 16 bit would be: ... (CopyOfADC << 6) | (CopyOfADC >> 4);

Note the span of 10 bits, the size of the real sample, when combining the two bit shifts.  The down shift isn't nessasary but does create the additional linear stepping throughout the full dynamic range.


Evan

39
Technical support / Re:Which Starter Kit?
« on: November 14, 2005, 01:03:19 AM »
TBASIC is effectively controlled by the Ladder Logic.  So you basically have a bunch of BASIC subroutines that are called from the ladder and can call each other.

It's not an either/or situation, rather TBASIC is used to perform data processing when the right logic becomes true.  Eg:  Checking voltage levels on the ADCs, performing math and string handling, issuing motion commands, updating the LCD, managing slaved communication devices and plenty more.


Evan

40
Technical support / Re:TLServer21.jar may not like J2SE 1.5.0
« on: November 11, 2005, 10:04:53 PM »
You beauty!  It also put a "serialio.jar" in .../lib/ext/


Cheers,
Evan

41
Technical support / How compiled is the code?
« on: November 11, 2005, 09:39:24 PM »
Here is my first test program that sits in a single custom function on a "Norm.On" rung.  There is a second DiffUpCustFunction on a 1.0 second pulse that prints the value of "j" to the LCD.  That's the whole program.

What I'm getting concerned about is that the below code continuously cycles at a rate of only 160 odd Hertz.  That is about one hundredth of the pace that I was hoping for.  :(

This function should compile to less than 40 instructions and if that's running in embedded program space on say a 10 MIPS core then we have a 4 microsecond execution time for this section which leaves 6246 usecs for the refresh cycle of two analogue inputs.  ;)


Code: [Select]
a = adc(1) : b = adc(2) 'Snap readings

i = (i + 1) & &H0f
j = j + 1
dm[i+1] = abs(a - b) 'Insert computed error
c = dm[1]+dm[2]+dm[3]+dm[4]+dm[5]+dm[6]+dm[7]+dm[8]+dm[9]+dm[10]+dm[11]+dm[12]+dm[13]+dm[14]+dm[15]+dm[16]
c = c * 3125/8192 'Convert to mA, (100 / 20 * 5000 / 4096 / 16)

if c > 100
  clrio RUNNING
endif


Evan

42
Technical support / Direct I/O
« on: November 11, 2005, 08:58:30 PM »
Is there any commands that perform direct I/O instead of working with the "refreshed" I/O data?

This is a very important feature within interrupts as the time it takes for a refresh cycle to be forced is usually excessive.


Evan

43
Technical support / Compile/Download bug
« on: November 11, 2005, 05:19:18 AM »
I'm not sure what's going wrong but having just written me first program for a T100MD+ I am a bit green on what's legal code and the procedure for downloading to the PLC.

What I've found is that using a custom function as an input bit in the ladder is not valid code.  A couple of interesting effects occur if one tries to do this:
 1 - The simulator compiles and runs without complaint.
 2 - The real PLC download doesn't even appear to attempt it's compile cycle and therefore doesn't send any code either.

So, apart from the discrepancy in the two procedures, there is no error or warnings produced by any of the compile runs.


Evan

44
Technical support / ADC normalisation
« on: November 11, 2005, 03:45:23 AM »
This is a recommendation:

The instruction manual states clearly that the normalisation is a simple bit shift that scales the value up to 12 bit resolution.  No complaints with the documentation.

However, I feel it'd be better if the scaling stretched to the full range of the 12 bit resolution.  It'd be a two or three instruction operation instead of the existing one instruction.  Something like:  
Code: [Select]
CopyOfADC = RealADC[x];  InternalADC[x] = (CopyOfADC << 2) | (CopyOfADC >> 8);

Cheers,
Evan

45
Technical support / Re:TL53.jar almost works native in Linux
« on: November 10, 2005, 09:37:12 PM »
Right, a quick google got me this, http://www.serialio.com/support/jspInstall.htm
It appears to be a commercial product that TRi will have paid for, https://serialio.com/store/advanced_search_result.php?keywords=serialport

I'm not too keen on purchasing this only to find it's not the complete fix.


Evan

Pages: 1 2 [3] 4